Python entry level applet (2)

Python entry level applet (2)

1. Output the date and time of the current computer

from datetime import datetime       #引用datetime库
now=datetime.now()                  #获得当前日期和时间信息
print(now)
now.strftime("%x")                  #输出其中日期部分
now.strftime("%x")                  #输出其中时间部分
  1. String splicing. Receive two character strings input by the user, combine them and output them.
str1=input("请输入人名:")
str2=input("请输入专业名称:")
print("{}就读于清华大学{}专业。".format(str1,str2))

3. Sum of integer sequences.

a=input("请输入一个整数N:")
sum=0
for i in range(int(a)) :
      sum+=i+1
      print("1到N求和结果:",sum)

4. Nine-nine multiplication table.

print("This is my first porgram!",end=',')
print("Thank you!")
for i in range(1,10):
  for j in range(1,i+1):
    print("{}×{}={}\t".format(j,i,i*j),end='')
print('')

5. Calculate 1+2! +3! +4! +…+10! Result

sum,tmp=0,1
for i in range(1,11):
   tmp*=i
   sum+=tmp
print("运算结果是:{}".format(sum))

Guess you like

Origin blog.csdn.net/Progresssing/article/details/107219426