# title1
fruit ="apples"
n =3
phraes ="i want"
print(phraes, n, fruit)
# title2
"""
如何命名: 数字,字母,下滑线组成,且不能以数字开头_apple = 3 true
3apple = 3 false
greenApple = 3 true
apple = 3 true
苹果= 3 false
apple3 = 3 true
"""
# title3
"""
字符串 string "我是一个字符串"
列表 list ["我", "是", "一个", "列表"]
整型int num = 3
布尔bool a = True
字典dict
元组tuple
集合set
"""
# title4
# int_num = input("你输入的整数是什么")
# shang = int(int_num)//3
# yushu = int(int_num)%3
# print("商是{}".format(shang))
# print("余数是{}".format(yushu))
# title5
#条件1 条件2
choose1 = [True,True]
choose2 = [True,False]
choose3 = [False,True]
choose4 = [False,False]
res1 =not choose1[0]and choose1[1]
res2 =not choose2[0]and choose2[1]
res3 =not choose3[0]and choose3[1]
res4 =not choose4[0]and choose4[1]
print(res1, res2, res3, res4)
# title6
x = ["how","hello, world","hello"]
x.append("hello")# ["how", "hello, world", "hello", "hello"]
x[2] ="world" # ["how", "hello, world", "world", "hello"]
x.remove("hello")# ["how", "hello, world", "world"]
print(x[2])
# tile7
print(len(x))
# title8 pass
# 闰年:能被400整除,或者能被4整除且不能100整除
# 如果这个年份能被100整除的话 :让他去判断能不能被400整除
# 如果这个年份都不能被100整除,直接判断被整除4
while True:
year =input("请输入你所需要查询的年份,输入exit退出程序")
if year =="exit":
print("退出程序")
break
if int(year) %100 ==0:
if int(year) %400 ==0:
print("{}是闰年".format(year))
continue
print("{}是平年".format(year))
continue
if int(year) %4 ==0:
print("{}是闰年".format(year))
continue
print("{}是平年".format(year))
continue
# title9
a ="ab2b3n5n2n67mm4n2"
lst = []
for charin a:
lst.append(char)
print(lst.count("n"))
# title10
count_n =0
for charin a:
if char =="n":
count_n = count_n +1
print(count_n)
# title11
print(a.count("n"))
网友评论