Getting example 1

1. Briefly variable naming

变量定义的规则:
1.变量由数字,字母,下划线组成
2.不能以数字开头
3.不能使用python中关键字
4.不能使用中文和拼音
5.区分大小写
6.变量名要具有描述性
7.官方推荐 下划线 写法

2.name = input ( ">>>") name variable what data type code detection

name = input(">>>")
print(type(name))


>>>kjk
<class 'str'>

The basic structure of 3.if conditional statement?

####
if  条件:
    执行语句
    
##    
if  条件:
    执行语句
elif  条件:
    执行语句
#
if  条件:
    执行语句
elif  条件:
    执行语句
else:
    执行语句
    
if  条件:
    if  条件:
        执行语句
        
else:
    执行语句

    

4. Print out the contents with the following print:

File can pick up a pen tranquility,
can force the ⻢ the moves.
Center Weighted deposit strategy Ho Face wins,
ancient and modern hero is the only monarch.

poem ="""
⽂能提笔安天下,
武能上⻢定乾坤.
⼼存谋略何⼈胜,
古今英雄唯是君.
"""
print(poem)

5. Use the if statement to write guess the size of the game:

An ideal setting numbers such as: 66, allowing users to enter a number, if larger than 66, the results show a big guess; if less than 66, the results show a small speculation; only equal to 66, the results show the correct guess.

num=int(input("请输入数字:"))
if num >66:
    print("太大了!")
elif num <66:
    print("太小了!")
else:
    print("正确!")

6. Tips Using the user to enter his age, the program proceeds ⾏ judgment.

If ⼩ to 10, Tips ⼩ fart child, if zoomed to 10, ⼩ 20, Tips adolescent rebellion ⼩ fart child. If zoomed to 20, ⼩ 30. Tips to start qualitative, began to mix ⼩ fart child society reach of children, if zoomed to 30, ⼩ 40. Tips to look old zoomed not ⼩, and quickly married ⼩ fart child reach of children. If zoomed to 40, ⼩ 50. Tips for home ⾥ have a disobedient child fart ⼩ reach of children. If zoomed to 50, ⼩ to become put on the monitor 60. Your Own ⻢ old fart disobedient child of reach of children. If zoomed to 60, ⼩ to 70. Tips are alive and good old fart child reach of children. If zoomed to 70, ⼩ to 90. Tips Face ⽣ nearing completion of ⼀ old fart child reach of children. If zoomed to 90 or more. Tips. ⻅ this world again.

age=int(input("请输入你的年龄:"))
if  age <10:
    print("小屁孩一枚。")
elif  age > 10 and age < 20:
    print("叛逆期的小屁孩!")
elif age >20 and age<30:
    print("加油哈好混!")
elif age >30 and age <40:
    print("老大不小了,该结婚了")
elif age >40 and age <50:
    print("家里又多了一个小屁孩")
elif  age >50 and age < 60:
    print("马上变成不听 话的老屁孩")
elif age >60 and age <70 :
    print("活着还不错的老屁孩⼉")
elif age>70 and age <90:
    print("⼈⽣就快结束了的⼀个老屁孩⼉")
else:
    print("再⻅了这个世界")

7. The multi-line and single line comment annotation representation

#
"""
dsadsadsadsad asd 
"""

8. Description of difference Python3 and Python2 you know?

python3代码实现了统一,代码没有重复的。

9. Use Tips Heige large user input. Using the user input is determined on the right. If, Tips very clever, if not, bad input Tips

name = input("请输入大黑哥:")
if  name = "大黑哥":
    print("真聪明")
else:
    print("输入错误")

10. Using the user input a START ⼀ months when then determines how much the Month Month. Depending on the Month, print different drink ⻝ (prepared according Face free diet and habits ⽼ house)

month=int(input("请输入月份数字:"))

data=('青岛','烟台','济南','威海','日照','菏泽','临沂','济宁','东营','泰安','日照','德州','莱芜')
if   month >0 and month <13:
    print(data[month])
else:
    print("请输入正确的月份数字!")

11. Using the user input a START ⼀ score. Using the user to determine the grade in accordance with test scores score

A 90 =
= 80 B
= 70 C
= 60 D
<60 fail

grade=int(input("请输入考试成绩:"))
if grade>=0 and  grade<=100:
    if  grade >=90 :
        print("A")
    elif grade >=80:
        print("B")
    elif grade >=70:
        print("C")
    elif grade >=60:
        print("D")
else:
    print("请输入正确的分数!")

Guess you like

Origin www.cnblogs.com/zdqc/p/11140826.html