python Chapter 6 Study Notes

# 6 Study Notes Chapter
## Introduction to
Python code, when executed in the order down on the self-executing.
Through the process control statements may change the execution order of the program, but also allows repeated a plurality of times specified program
flow control statements divided into two categories: conditional statements, loop

## conditional statement (if statement)
Exercise 1:
Write a program, get a integer user input. Then displays this number is odd or even.

Exercise 2:
Write a program that checks whether any one year is a leap year.
If a year divisible by 4 is not divisible by 100, or may be divisible by 400, this year is a leap year

Exercise 3:
Our dog, 5 years old, 5-year-old dog is equivalent to how old people do?
In fact, very simple, two years before the dog is equivalent to 10.5 years of mankind every year, then every additional year increases the age of four.
Then 5-year-old dog is equivalent to the human age should be 10.5 + 10.5 + 4 + 4 + 4 = 33 years old

Write a program, get a dog's age entered by the user, then the program displays its human equivalent of age.
If the user enters a negative number, display a message

Exercise 4:
Enter Xiaoming final grade from the keyboard:
When the score of 100, 'reward a BMW'
when the score [80-99], 'reward a iphone'
when the score [60-79], the ' award a reference book '
other time, any award nor

Exercise 5:
we all know, men and when the marriage, a girl, once married. Then the woman's parents to marry off their daughters, of course, to put forward certain conditions:
high: more than 180cm; rich: more than 10 million; Shuai: 500 or more;
If these three conditions are met, then: 'I must marry him'
if the three conditions really promising situation, then: 'marry it, better than some, worse than the next. '
If the three conditions are not met, then:' do not marry! '

## loop
Exercise 1:
demand within the sum of all the odd 100

Exercise 2:
within 100 request and all multiples of 7, and the number

Exercise 3:
number refers to a daffodils n bits (n ≧ 3), on which the digital bit of each n-th power sum equal to itself (for example: 3 + 1 * 3 + 3 * 5 ** * 3 = 153).
Find all the numbers less than 1,000 daffodils

Practice 4:
acquiring arbitrary number input by the user, determines whether it is a prime number. Prime number is divisible only by itself and the number of 1, 1 is not a prime nor composite.

## nested loop
Exercise 1:
print multiplication table 99
1 * 1 = 1
1 = 2 * 2 * 2 = 4 2
1 2 * 3 * 3 = 63 = 3 * 3 = 9
... 9 * 9 = 81

Exercise 2:
find all the prime numbers less than 100

## games "Skeleton Demon Monkey Wars"
1, the identity selector
① the display message
Welcome xxx game!
Please select your identity:
1.xxx
2.xxx
Please select: the X-
② to assign the identity of the user to select (display a different prompt message)
1 .---
2 .---
3 .---

2, the game
① displays basic information about the player (ATK value of life)
② player display operation can be performed:
1, leveling
- enhance the player's attack power and hit points
2, playing BOSS
- BOSS attack players, the player to attack BOSS, BOSS for players to fight back
- calculate whether the player destroys BOSS, BOSS whether the player is to destroy
- the game is over
3, escape
- quit the game, display a message, the end of the game!

Guess you like

Origin www.cnblogs.com/mylive/p/12537477.html