'''
@Author: your name
@Date: 2020-07-05 22:55:33
@LastEditTime: 2020-07-05 23:43:41
@LastEditors: Please set LastEditors
@Description: In User Settings Edit
@FilePath: \vscode_py\day1.py
'''

# Question 1:
# Write a program which will find all such numbers which are divisible by 7 but are not a multiple of 5,
# between 2000 and 3200 (both included).The numbers obtained should be printed in a comma-separated sequence on a single line.
def Question1():
for i in range(2000,3201):
if i % 5 !=0 & i%7==0:
print(i,end=",") # end=','意思是末尾不换行,加逗号

# Question2:
# Write a program which can compute the factorial of a given numbers.
# The results should be printed in a comma-separated sequence on a single line.
# Suppose the following input is supplied to the program: 8 Then, the output should be:40320
def Question2():
n=int(input())
fact=1
# i=1
# while i<=n:
# fact=fact*i
# i=i=1
for i in range(1,n+1):
fact=fact*i


print(fact)

def lamQ2(x):
return 1 if x<=1 else x*lamQ2(x-1)

# #Question 3:
# With a given integral number n, write a program to generate a dictionary that contains (i, i x i)
# such that is an integral number between 1 and n (both included). and then the program should print the dictionary.
# Suppose the following input is supplied to the program: 8
def Question3():
n=int(input())
dic={}
for i in range(1,n+1):
dic[i]=i*i
print(dic)

# Using dictionary comprehension
def Q3():
n=int(input())
print({i:i*i for i in range(1,n+1)})

if __name__ == "__main__":
# Question1()

# Question2()
# x=int(input())
# print(lamQ2(x))

# Question3()
Q3()

github:
​​​ https://github.com/darkprinx/100-plus-Python-programming-exercises-extended​