欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

部分初学时练手的代码

程序员文章站 2022-04-27 22:30:13
...
打印世界你好!
print(num2, 'is biggest')


猜年龄
my_age= 22
a = guess_age =int(input("guess age is ;"))

c=1
while c==1:
a = guess_age =int(input("guess age is ;"))
if a == my_age:
print('yes ')
break
elif a < my_age:
print('try bigger')
else :
print('try smaller')

你还能活多久

DeathAge= 110
name = input('you name :')
a =age = input('you age :')
a = int(a)
print('Dear ',name, 'you can only live',DeathAge - a,'good luck to you ')

输出 输入长宽的#字的方体
length = int(input('length:'))
width = int (input('width:'))
a = 1
while a <= length:
print("#",end='')
b=0
while b <= width :
print('#',end="")
b +=1
a +=1
print()



判断输入3个数字最大值


num1 = int(input('num1:'))
num2 = int(input('num2:'))
num3 = int(input('num3:'))
max = num1
if num1 > num3 :
print(num1,'is biggest')
else :
print(num3,'is biggest')
else :
if num2 > num3:
print(num2, 'is biggest')
else :
print(num3, 'is biggest')