python123程序设计题说句心里话(python语言程序设计编程题)
Python123 Python语言程序设计 -无空隙回声输出
第一题:无空隙回声输出
描述
获得用户输入,去掉其中全部空格,将其他字符按收入顺序打印输出。
答案:
(```)
s = input()
print(s.replace(" ",""))
(```)
用Python语言设计程序,5道题,谢谢!
第一题,用input()接受用户输入,int()把输入转换成整型,if... else语句判断条件。能被2整除的是偶数,否则奇数
代码:
n = int(input())
if n % 2 == 0:
..#前面的点表示缩进。
..print("是偶数")
else:
..print("是奇数")
第二题input()、int()和嵌套if语句
代码:
n = int(input())
if n % 100 != 0:
..if n % 4 == 0:
....print("是闰年")
..else:
....print("是平年")
elif n % 400 == 0:
..print("是闰年")
else:
..print("是平年")
第三题还是一样滴,用input(),int()和if...else语句
代码:
a = int(input())
b = int(input())
if a b:
..print(a – b)
else:
..print(b – a)
第四题也是一样滴
代码:
m = int(input())
n = int(input())
if m n:
..print(m, n)
else:
..print(n, m)
第五题 (*^▽^*)
代码:
a = int(input())
if a =60:
..print("合格")
else:
..print("不合格")
python简单程序设计:许多计算机程序系统都需要登录,且要求账号密码输入错误不得超过三次?
##注意:最左边每个=表示一个空格
##修改成你的姓名
name="aabb"
c,userinfo=0,{"account":"123","password":"456","count":3}
t=input("请输入账号:")
while t!=userinfo["account"] and c=userinfo["count"]:
====c=c+1
====t=input("账号错误,请重新输入:")
if c=userinfo["count"]:
====t=input("请输入密码:")
====while t!=userinfo["password"] and c=userinfo["count"]:
========t=input("密码错误,请重新输入:")
========c=c+1
if c=userinfo["count"]:
====print("欢迎%s登录到本系统!" %name)
else:
====print("你登录次数过多。%s,请联系管理员。" %name)