Commit ecf275e4 by BellCodeEditor

save project

parent 337747d3
#获取字符串
#逆序输出
#输出包含字符个数
s = input()
print(s[::-1],end="\n")
print(len(s))
\ No newline at end of file
#开始是熄灭
#输入正整数M(1<m<100)
#判断拉M次亮还是熄
#输入正整数M作为次数
#输出如果灯是点亮状态输出“1”,否则输出“0”
a=int(input())
if a%2==0:
print("0")
else:
print("1")
\ No newline at end of file
#输入字母数字的混合
#然后统计显示在屏幕
ns=input("输入字符串:")
dnum=0
dchr=0
for i in ns:
if i.isnumeric():
dnum+=1
elif i.isalpha():
dchr+=1
else:
pass
print("数字个数:"+str(dnum)+",字母个数:"+str(dchr))
\ No newline at end of file
#单价160
#1个0折
#2~4个 9折
#5~9个 8折
#10=<个 7折
#输入数量 输出价格(保留整数)
#例:
#输入:1
#输出:总额为:160
n=int(input("数量:"))
if n>0 and n<=1:
cost=n*160
elif n<=4:
cost=n*160*0.9
elif n<=9:
cost=n*160*0.8
else:
cost=n*160*0.7
cost=int(cost)
print("总额:",cost)
\ No newline at end of file
#键盘输入列表b
#计算a中元素与b中元素的和形成的列表c在屏幕上输出
#例:键盘输入列表b为[1,2,3]
#屏幕输出的计算结果为[4,8,12]
a=[3,6,9]
b=eval(input())
c=[]
for i in range(3):
c.append(a[i]+b[i])
print(c)
\ No newline at end of file
#判断输入的数字是否为正整数
#否,则显示: 输入正整数
#直至输入正整数为止并显示
while True:
a=eval(input('请输入一个正整数:'))
if a >0 and int(a)==a:
print(a)
break
else:
print("请输入正整数:")
\ No newline at end of file
#随机选择手机品牌列表中的一个手机品牌在屏幕输出
import random
brandlist=['华为','Apple','诺基亚','OPPO','小米']
i=random.randint(0,4)
name=brandlist[i]
print(name )
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment