def print_paras(fpara, *nums, **words):
print("fpara: " + str(fpara))
print("nums: " + str(nums))
print("words: " + str(words))
print_paras("hello", 1, 3, 5, 7, word="python", anohter_word="java")
# fpara: hello
# nums: (1, 3, 5, 7)
# words: {‘word‘: ‘python‘, ‘anohter_word‘: ‘java‘}
# Process finished with exit code 0
# if语句
number = 59
guess = int(input(‘Enter an integer:‘))
if guess == number:
print(‘guess right‘)
elif guess < number:
print(‘too small‘)
else:
print(‘lower‘)
# for 语句
for i in range(1,10):
print(i)
else:
print(‘over‘)
a_list = [1,3,5,7,9]
for i in a_list:
print(i)
a_tuple = (1,3,5,7)
for i in a_tuple:
print(i)
a_dict = {‘Tom‘:‘111‘,‘jerry‘:‘222‘,‘catty‘:‘333‘}
for ele in a_dict:
print(ele)
print(a_dict[ele])
for key,elem in a_dict.items():
print(key,elem)
# catty
# 333
# jerry
# 222
# Tom
# 111
# catty 333
# jerry 222
# Tom 111
number = 59
guess_flag = False
while guess_flag == False:
guess = int(input(‘Enter an integer : ‘))
if guess == number:
# New block starts here
guess_flag = True
# New block ends here
elif guess < number:
# Another block
print(‘No, the number is higher than that, keep guessing‘)
# You can do whatever you want in a block ...
else:
print(‘No, the number is a lower than that, keep guessing‘)
# you must have guessed > number to reach here
print(‘Bingo! you guessed it right.‘)
print(‘(but you do not win any prizes!)‘)
print(‘Done‘)
# Enter an integer : 5
# No, the number is higher than that, keep guessing
# Enter an integer : 59
# Bingo! you guessed it right.
# (but you do not win any prizes!)
# Done