You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
hnit22050140332 2bf8dc5d91
Update README.md
3 years ago
2 ADD file via upload 3 years ago
README.md Update README.md 3 years ago

README.md

1整数

a,b = map(eval,input().split(";")) print("sum={}".format(a+b))

2身份证 id = input() if len(id) !=18: print("您输入的身份证位数不正确") else id_1 = id[0:17] id_2 = id[17] if id_1.isdigit(): n = int(id[16]) if n % 2 == 0: print('性别女') else: print('性别男') else printid 3闰年 year = int(input()) if(year%400==0)or(year%4==0 and year%100!=0): print(True) else: print(False)

4列表基本操作 num=[11,13,17,19] print(num[1]) num.append(23) num.append(25) print(num[2:5]) print(num*3) num[-1]=27 print(sum(num)) num.reverse() print(num) num.remove(17) print(len(num)) print(max(num)) print(num.index(19)) 6抽奖 import random as r import time r.seed(10) n = int(input())

print(“倒计时开始”) for i in range(n): print(n-i) print("陈思涵") 7统计每个区间落入的数字 N,Q=map(int,input().split()) ls=list(map(int,input().split())) for i in range(Q): A,B=map(int,input().split()) s=0 for K in is: if K>=A and K<=B: s=s+1 print(s)

8股票数据 import matplotlib as mpl mpl.use('Agg') import matplotlib.pyplot as plt import datetime

def Draw(): appl = "step3/AAPL.csv" google = "step3/GOOG.csv" ms = "step3/MSFT.csv"

plt.xticks(rotation=45) #`x`轴的坐标设置倾斜`45`度
#调用Read函数读取苹果公司的数据返回日期和开盘价
 #在此绘制折线图
#   请在此添加实现代码   #
# ********** Begin *********#
appdate,appopens = Read(open(appl))
godate,googopens = Read(open(google))
msdate,msopens = Read(open(ms))

plt.plot(appdate,appopens,label='Apple',color='green',linewidth=1.2)
plt.plot(godate,googopens,label='Google',color='blue',linewidth=1.2)
plt.plot(msdate,msopens,label='Microsoft',color='red',linewidth=1.2)
# ********** End **********#
plt.legend(loc='best')
plt.savefig("step3/output/data.png")   #保存图片

def Read(file): #Read函数用于读取file解析文件中的数据 dates = [] opens = [] file.readline() for line in file.readlines(): i1 = line.index(',',0,len(line)) dt = datetime.datetime.strptime(line[0:i1],"%Y-%m-%d").date() dates.append(dt) i2 = line.index(',',i1 + 1,len(line)) opens.append(float(line[i1 + 1:i2])) file.close() return dates,opens 5回文素数 def is_prime(num): """ 判断一个数是不是素数 :param num: 正整数 :return: 是素数返回True不是素数返回False """ # 请在此处添加代码 # # *begin# if num < 2: return False for i in range(2,int(num ** 0.5) + 1): if num % i == 0: return False return True # *end#

def is_palindrome(num): """ 判断一个数是不是回文数 :param num: 正整数 :return: 是回文数返回True不是回文数返回False """ # 请在此处添加代码 # # *begin# s = str(num) return s== s[::-1] # *end# def prime_palindrome(num): """ 判断一个数是不是回文素数 :param num: 正整数 :return: 是回文素数返回True不是回文素数返回False """ # 请在此处添加代码 # # *begin# return is_palindrome(num) and is_prime(num) # *end#