the Way of Python Day 1

---恢复内容开始---

firstly,i already have learned how to compile a hello world program:

print("hello,world ")

secondly,i learned about how to express the type of a variable:

print(type(variable name))

thirdly,i mastered a way to input strings and a approach to do combination of strings:

death_age=100

name=input("your name :")

age=input("your age :")

print("your can still live for",death_age-int(age),"years")

print("your can still live for"+str(death_age-int(age))+"years")

扫描二维码关注公众号,回复: 803662 查看本文章

(PS:the way to input gets digitals that belong to strings,all belong to strings,so if you input a number,

please transform it to integer)

at the end i learned how to use if...else and elif(=if else),and i mastered the usages of them:

age_of_principal = 56
guess_age = int(input('>>:'))
if guess_age==age_of_principal:
print('yes,you got it')
elif guess_age>age_of_principal:
print('should try smaller...')
else :
print('should try bigger')

or

score=int(input('score= '))
if score>90:
print('A')
elif score>80:
print('B')
elif score>70:
print('C')
elif score>60:
print('D')
else :
print('滚')

---恢复内容结束---

firstly,i already have learned how to compile a hello world program:

print("hello,world ")

secondly,i learned about how to express the type of a variable:

print(type(variable name))

thirdly,i mastered a way to input strings and a approach to do combination of strings:

death_age=100

name=input("your name :")

age=input("your age :")

print("your can still live for",death_age-int(age),"years")

print("your can still live for"+str(death_age-int(age))+"years")

(PS:the way to input gets digitals that belong to strings,all belong to strings,so if you input a number,

please transform it to integer)

at the end i learned how to use if...else and elif(=if else),and i mastered the usages of them:

age_of_principal = 56
guess_age = int(input('>>:'))
if guess_age==age_of_principal:
print('yes,you got it')
elif guess_age>age_of_principal:
print('should try smaller...')
else :
print('should try bigger')

or

score=int(input('score= '))
if score>90:
print('A')
elif score>80:
print('B')
elif score>70:
print('C')
elif score>60:
print('D')
else :
print('滚')

猜你喜欢

转载自www.cnblogs.com/margin1314/p/9034947.html