python训练馆_Python训练营(二)

#条件语句 if

#if 2 > 1 and not 2 > 3:

# print('Correct Judgement!')

#if-else

#if 2 > 1 and not 2 > 3:

# print('Correct Judgement!')

'''temp = input("猜一猜小姐姐想的是哪个数字?")guess = int(temp) # input 函数将接收的任何数据类型都默认为 str。if guess == 666:print("你太了解小姐姐的心思了!")print("哼,猜对也没有奖励!")else:print("猜错了,小姐姐现在心里想的是666!")print("游戏结束,不玩儿啦!")'''

'''h = 0if h > 1:print("good")else:print("bad")'''

'''temp = input("猜猜输入的哪个数字")guess = int(temp)if guess > 8:print("大了")elif guess == 8:print("猜对了也没奖励")else:print("小了")print("游戏结束")'''

#assert 3 > 7

'''my_list = ['lsgogroup']my_list.pop(0)assert len(my_list) > 0'''

'''count = 0while count < 3:temp = input("猜猜哪个数字\n")guess = int(temp)if guess > 8:print("大了,大了")elif guess == 8:print("猜对了")count = 3else:print("小了小了")count = count+1print("游戏结束")'''

'''#切片操作string = 'abcd'while string:print(string)string = string[1:]'''

'''count = 0while count < 5:print("%dis less than 5"% count)count = count + 1else:print("%dis not less than 5"% count)'''

'''for i in 'ILOVELSGD':print(i, end=' ')'''

'''member = ['张三', '李四', '刘德华', '刘六', '周润发']for i in member:print(i) #print默认换行'''

'''dic = {'a': 1, 'b': 2, 'c': 3, 'd': 4}for key, value in dic.items():print(key, value, sep=':', end=' ')dic = {'a': 1, 'b': 2, 'c': 3, 'd': 4}for key in dic.keys():print(key, end=' ')dic = {'a': 1, 'b': 2, 'c': 3, 'd': 4}for value in dic.values():print(value, end=' ')'''

'''for num in range(10, 20): # 迭代 10 到 20 之间的数字for i in range(2, num): # 根据因子迭代if num% i== 0: # 确定第一个因子j = num / i # 计算第二个因子print('%d等于%d*%d' % (num, i, j))break # 跳出当前循环else: # 循环的 else 部分print(num, '是一个质数')# 10 等于 2 * 5# 11 是一个质数# 12 等于 2 * 6# 13 是一个质数# 14 等于 2 * 7# 15 等于 3 * 5# 16 等于 2 * 8# 17 是一个质数# 18 等于 2 * 9# 19 是一个质数'''

'''#枚举seasons = ['Spring', 'Summer', 'Fall', 'Winter']lst = list(enumerate(seasons))print(lst)# [(0, 'Spring'), (1, 'Summer'), (2, 'Fall'), (3, 'Winter')]lst = list(enumerate(seasons, start=1)) # 下标从 1 开始print(lst)# [(1, 'Spring'), (2, 'Summer'), (3, 'Fall'), (4, 'Winter')]'''

x = [i for i in range(100) if (i % 2)!= 0 and (i % 3)== 0]

print(x)

你可能感兴趣的:(python训练馆)