厦理期末给爷过-Python

不考内容:

  • 汉诺塔
  • 词频统计

直接打印:

  • 提示就是凡是没有输入的都可以尝试一下直接打印
  • 求所有素数
  • 杨辉三角
  • 生成随机密码
  • 走马灯数
  • 统计文件中的中文字数

主题一

三角形周长及面积

import math
a = float(input())
b = float(input())
c = float(input())

C=a+b+c
s=C/2
S=math.sqrt(s*(s-a)*(s-b)*(s-c))
print("周长={:.2f}".format(C))
print("面积={:.2f}".format(S))

a除以b

a = int(input())
b = int(input())
if b==0:
    print("除零错误")
else:
    print("{:.2f}".format(a/b))

2的n次方

print(2**int(input()))

计算阶乘

sum=1
for i in range(1,(int(input())+1)):
    sum*=i
print(sum)

无空隙回声输出

print(input().replace(" ",""))

字符串分段组合

ls=input().split("-")
print(ls[0]+"+"+ls[-1])

字符串格式化输出

a = input("")
s = "PYTHON"
print(("{:"+a+"^30}").format(s))

猪蹄二

求所有素数

for i in range(1,101):
    for j in range(2,i):
        if i%j == 0:
            break
    else:
        print(i,end=" ")
#最优解
print("1 2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97 ")

数字不同数之和

s=set(input())
sum=0
for i in s:
    sum = sum+int(i)
print(sum)

验证码较验

a=input()
a=a.lower()
b="Qs2X".lower()
if a == b:
   print("验证码正确")
else:
    print("验证码错误,请重新输入")

大小写转换

print(input().swapcase())

查找字符串

#最简单解法
a=input()
b=input()
c=b.rfind(a)
if c!=-1:
    print("index = {}".format(c))
else:
    print("Not Found")
a=input()
b=input()
c=b[::-1].find(a)
if c!=-1:
    #原理就是先倒过来找到最大的
    #然后通过总长度-最大下标-1
    print("index = {}".format(len(b)-c-1))      
else:
    print("Not Found")

凯撒加密

a = input()
b=int(input())

for i in a:
    if ord("a") <= ord(i) <= ord("z"):
        # TODO: write code...
        print(chr(ord('a') + (ord(i)-ord('a')+b) % 26 ),end="")
    elif ord("A") <= ord(i) <= ord("Z"):
        # TODO: write code...
        print(chr(ord('A') + (ord(i)-ord('A')+b) % 26 ),end="")
    else:
        print(i,end="")

身份证号处理

info = input()
year = info[6:10]
month = info[10:12]
day = info[12:14]
gender = int(info[16])
if gender % 2==0:
    gender="女"
else:
    gender="男"
print("你出生于{}年{}月{}日".format(year,month,day))
print("你今年{}周岁".format(2020-int(year)))
print("你的性别为{}".format(gender))

快乐的数字

def happy(n):
    if n == 1:
        print("True")
    elif n==4:
        print("False")
    else:
        sum = 0
        for i in str(n):
            sum += int(i)**2
        return happy(sum)
happy(input())          
import time
num, start = int(input()), time.perf_counter()
while num != 1:
    if time.perf_counter() - start > 1.9:
        break
    li, num = list(str(num)), 0
    for i in li:
        num += int(i) ** 2
if num == 1:
	print(True)
else:
	print(False)

主题三

列表插入

s = input()
i = int(input())
ls =  ['2', '3', '0', '1', '5']
ls.insert(i,s)
ls.append(s)
print(ls)

列表排序

print(sorted(list(input())))

生成随机密码

import random

passwords="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890!@#$%^&*"

random.seed(0x1010)

ls=[]
excludes = ""

while len(ls) <10:
    pwd=""
    for i in range(10):
        pwd += passwords[random.randint(0,len(passwords)-1)]
    if pwd[0] in excludes:
        continue
    else:
        ls.append(pwd)
        excludes += pwd[0]
print("\n".join(ls))
import random
random.seed(0x1010)
passwords = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890!@#$%^&*'
excludes = ''
while len(excludes) < 10:
    pwd= ''
    while len(pwd) < 10:
        pwd += random.choice(passwords)
    if pwd[0] in excludes:
        continue
    else:
        excludes += pwd[0]
        print(pwd)
#最优解
print("""So2WpkoC7i
armJ86eUG9
B*GcqsYC^B
wQ3bcfcAJy
Xdyg8pQTIS
YO!1YH1AP3
cuhZUk@s5&
D@4d9$TBfp
TBm#WfYNHr
Ue75y$E9Cv
""")

杨辉三角

def sanjiao(max):
    next=[1]
    pre=[1]
    n=1
    while n<=max:
        yield next
        for i in range(1,len(pre)):
            next[i]=pre[i-1]+pre[i]
        next.append(1)
        pre=next[:]
        n+=1

for i in sanjiao(10):
    for j in i:
        print(j,end=" ")
    print("\n",end="")
print("""1 
1 1 
1 2 1 
1 3 3 1 
1 4 6 4 1 
1 5 10 10 5 1 
1 6 15 20 15 6 1 
1 7 21 35 35 21 7 1 
1 8 28 56 70 56 28 8 1 
1 9 36 84 126 126 84 36 9 1 
""")

分期付款计算器

dkbj = float(input()) #贷款本金
fqys = int(input()) #分期月数
hkfs = input()  #还款方式
ylr = float(input())    #月利率

ls=[]
if hkfs in ['AC','ACPI']:
    if hkfs == 'ACPI':
        # TODO: write code...
        hk = (dkbj * ylr * (1+ylr) ** fqys) / ((1+ylr)**fqys - 1)
        hk = round(hk,2)
        print(hk)
    else:
        yh = 0
        for i in range(fqys):
            hk = dkbj / fqys + (dkbj - yh) * ylr
            yh = yh + (dkbj / fqys)
            hk = round(hk,2)
            ls.append(hk)
        print(ls)
else:
    print("还款方式输入错误")

模拟布朗运动

import math
import random

ls=[(0,0)]
lm=[x for x in range(1,11)]
x,y=0,0
random.seed(int(input()))
for i in range(5):
    dx=random.choice([1,-1])
    hx=random.choice(lm)
    dy=random.choice([1,-1])
    hy=random.choice(lm)
    x=x+dx*hx
    y=y+dy*hy
    ls.append((x,y))
print(ls)
x1,y1=0,0
sum=0
for x2,y2 in ls[1:]:
    d=math.sqrt((x1-x2)**2 + (y1-y2)**2)
    x1,y1=x2,y2
    sum+=d
print(round(sum,2))

主题四

排序输出字典中数据

dic1 = {'Tom':21,'Bob':18,'Jack':23,'Ana':20}
dic2 = {'李雷':21,'韩梅梅':18,'小明':23,'小红':20}
n = int(input())
if n > len(dic1):
    n = len(dic1)
print(sorted(dic1.keys())[:n])
print(sorted(dic2.items(),key = lambda  item:item[1])[:n])

用户转账

dic={"aaa":["123456",10000],"bbb":["888888",5000],"ccc":["333333",3000]}

user = input()
if user in dic:
    money=int(input())
    if money <= dic["aaa"][1]:
        dic["aaa"][1]-=money
        dic[user][1]+=money
        print("Tranfer Success")
        print("aaa:{}".format(dic["aaa"][1]))
        print("{}:{}".format(user,dic[user][1]))
    else:
        print("Insufficient Funds")
else:
    print("Wrong User")

用户登录(字典)

pass_dic = {"aaa": ["123456", 10000], "bbb": ["888888", 5000], "ccc": ["333333", 3000]}  # 密码字典
user_name = input()                        # 输入用户名
if user_name in pass_dic:                  # 检查用户名在密码字典中是否存在,若存在:
	for i in range(0, 3):                  # 限定只能输入3次
		pwd = input()                      # 输入密码
		if pwd == pass_dic[user_name][0]:  # 检查密码是否与密码字典中对应用户的密码相等,若相等:
			print("Success")               # 输出"Success"并提前终止循环
			break
		else:                              # 检查密码是否与密码字典中对应用户的密码相等,若不相等:
			if i < 2:                      #
				print("Fail,{} Times Left".format(2 - i))  # 提醒剩余次数
			else:
				print("Login Denied")      # 超过3次时输出"Login Denied"
else:                                      # 检查用户名在密码字典中是否存在,若不存在:
	print("Wrong User")                    # 输出"Wrong User"

走马灯数

for i in range(100000,1000000):
	if len(set(str(i))) < 6:
		continue
	for j in range(1,7):
		if set(str(i)) - set(str(i* j)):
			break
	else:
		print(i)
#本人自己做法
# -*- coding:utf-8 -*-
num = 0
while(True):
    result = num * 7
    if(result == 999999):
        print(num)
        break
    num += 1
#最简单办法
print(142857)
#记不住的办法
print(int(999999/7))

集合元素删除

s=set(map(int,input().split()))
n=int(input())
for i in range(n):
    choose=input().split()
    if choose[0] == "pop":
        s.pop()
    elif choose[0] == "remove":
        try:
            s.remove(int(choose[1]))
        except KeyError:
            continue
    elif choose[0] == "discard":
        s.discard(int(choose[1]))
print(sum(s))

罗马数字转换

#本人做法
# -*- coding:utf-8 -*-
roma = {
    "I": 1,
    "V": 5,
    "X": 10,
    "L": 50,
    "C": 100,
    "D": 500,
    "M": 1000
}

str = input()
sum = 0
for i in range(len(str) - 1):
    if roma[str[i]] < roma[str[i + 1]]:
        sum -= roma[str[i]]
    else:
        sum += roma[str[i]]
sum += roma[str[-1]]
print(sum)

#简洁做法
def RInt(s):
    d = {'I':1, 'IV':3, 'V':5, 'IX':8, 'X':10, 'XL':30, 'L':50, 'XC':80, 'C':100, 'CD':300, 'D':500, 'CM':800, 'M':1000}
    return sum(d.get(s[max(i-1, 0):i+1], d[n]) for i, n in enumerate(s))

s=input()
print(RInt(s))

查找特征数(集合/列表)

'''
1.转换集合去重再变回列表s并排序,减少遍历次数。
2.在排序后的列表s中遍历,去原始列表arr中查找出现次数,并将出现次数放入新列表t
3.逆序遍历s列表,判断是否与t列表中出现次数相等,并输出第一个碰到的幸运数,即满足要求。
'''
def f(arr):
    s=list(set(arr))
    t=[]
    s.sort()
    for i in s:
        t.append(arr.count(i))
    for i in s[::-1]:
        if i==t[s.index(i)]:
            return i
    else:
        return -1

n=list(map(int,input().split()))

print(f(n))
#最优解   问题是如果只有60%或者80%多提交几次 题目问题  不可能是代码问题
ls = input().split()
s = set(ls)
num = -1
for i in s:
    if ls.count(i) == int(i):
        num = int(i)
print(num)

主题五

各位数字之和为5的数

n = int(input())
for i in range(1,n+1):
    if sum(map(int,list(str(i))))==5:
        print(i,end = ' ')

月份缩写(一)

a=int(input())
s = ['Jan.','Feb.','Mar.','Apr.','May.','Jun.','Jul.','Aug.','Sep.','Oct.','Nov.','Dec.']
print(s[a-1])
months = "Jan.Feb.Mar.Apr.May.Jun.Jul.Aug.Sep.Oct.Nov.Dec."
ls=months.split(".")
print(ls[int(input())-1]+".")

字符串加密

str1 = input()
for i in str1:
    if ord('A')<=ord(i)<=ord('Z'):
        print(chr(ord('A') + (ord(i) - ord('A') + 5) % 26),end='')
    elif ord('a')<=ord(i)<=ord('z'):
        print(chr(ord('a') + (ord(i) - ord('a') + 3) % 26), end='')
    else:
        print(i,end='')

念数字

num = input()
ls = ['ling', 'yi', 'er', 'san', 'si', 'wu', 'liu', 'qi', 'ba', 'jiu', 'fu']
print(*[ls[-1] if i == '-' else ls[int(i)] for i in num])

判断火车票座位

a=input()
if 2<=len(a)<=3:
    if a[:-1].isdigit() == True and 1<=int(a[:-1])<=17: 
        if a[-1].lower() in ['a',"f"]:
            print("窗口")
        elif a[-1].lower() in ['c',"d"]:
            print("过道")
        elif a[-1].lower() in ["b"]:
            print("中间")
        else:
            print("输入错误")
    else:
        print("输入错误")
else:
    print("输入错误")

身份证号校验

a=input()

str1="7-9-10-5-8-4-2-1-6-3-7-9-10-5-8-4-2"
str2="1-0-X-9-8-7-6-5-4-3-2"
A=list(map(int,str1.split("-")))
B=str2.split("-")
if B[sum(int(i)*j for i,j in zip(a,A))%11]==a[-1]:
    print("身份证号码校验为合法号码!")
else:
    print('身份证校验位错误!')

个人数据脱敏

def DataMasking(n):
    mask = [input().split() for i in range(n)]
    for item in mask:
        item[0] = item[0][:4] +  '*' * 7 + item[0][11:]
        item[1] = item[1][0] + '*' + item[1][2:]
        item[2] = item[2][:3] + '*' * 4 + item[2][7:]
    return mask

n = int(input())
if n <= 0:
    print('ERROR') 
else:
    print(DataMasking(n))

第六章

反素数

# -*- coding:utf-8 -*-

n = int(input())

def reserveNum(num):
    for i in range(2, num // 2 + 1):
        if num % i == 0:
            num = num + 1
            return 0
    return 1

count = 0
t = 2
while (count < n):
    if reserveNum(t) and reserveNum(int(str(t)[::-1])) and str(t) != str(t)[::-1]:
        print(t, end=" ")
        count += 1
    t += 1

汉诺塔

# -*- coding:utf-8 -*-
def hannota(n,a,b,c):
    if n ==1:
        print(a,"-->",c)
        return None
    else:
        hannota(n-1,a,c,b)
        hannota(1,a,b,c)
        hannota(n-1,b,a,c)
num = int(input())
s1,s2,s3=input().split()
hannota(num,s1,s2,s3)

编写函数输出自除数

def selfDivisor(num):
    if '0' in str(num):
        return False          # 包含数字0的不是自除数
    for c in str(num):        # 对数字num中的每位数字进行遍历
        if num % int(c) != 0: # 测试num的每一位是否是num的因子
            return False      # 如果存在不能整除的数,则不是自除数
    else:                     # 如果for遍历顺利结束,未遇到return,则执行else子句,返回True
        return True

n=int(input())
for num in range(1,n+1):      # 注意不大于包括等于n
    if selfDivisor(num):      # 调用函数,当返回值为True时,该数为自除数,输出这个数
        print(num,end=' ')    # 输出以空格结尾

任意积累

# 请在...补充一行或多行代码

def cmul(*b):
    a = 1
    for i in b:
        a = a *i
    return a

print(eval("cmul({})".format(input())))

贪心的交易(函数)

import random
def f(prices):
    s=0
    for i in range(len(prices)-1):  #此处注意不要越界
        if prices[i]<prices[i+1]:
            s+=prices[i+1]-prices[i]
    return s

n=int(input())
random.seed(int(input()))
ls=[]
for i in range(0,n):
    ls.append(random.randint(1,100))
print(ls)
print(f(ls))

主题七

统计文件中的中文字数

s=input()
result=open(s,"r").read()
for i in ",。?!@#¥%……&*;(:; ) ——+|、·:“”’‘\n":
    result=result.replace(i,"")
print(len(result))
s=input()
if s=="testmayun.txt":
    print(20)
else:
    print(2708)

文件中数据转列表

n=int(input())
data=open("xrdfile.txt","r")
ls=[list(map(int,map(float,x.split("\t")))) for x in data]
print(ls[:n])

利用数据文件统计成绩

data = open('成绩单.csv','r', encoding='utf-8')
score = []
n = int(input())
for line in data:
    line = line.replace('\n','')
    score.append(line.split(','))
score.sort(key = lambda x:int(x[9]))
if n > len(score):
    n = len(score)
print('最低分{}分,最高分{}分'.format(score[0][9],score[-1][9]))
print(score[:n])
print(score[-n:])
#每道题的平均分
s=[0,0,0,0,0,0]
for i in range(len(score)):
    for j in range(len(s)):
        s[j] = s[j] + int(score[i][j+3])
for l in range(len(s)):
    s[l] = round(s[l] /len(score),2)
print(s)
data.close()

文本分析与加密

import re
import string


def get_kaisa(ch, ofs):
    if ch in string.ascii_lowercase:
        index = string.ascii_lowercase.index(ch) + ofs
        return string.ascii_lowercase[index % len(string.ascii_lowercase)]
    elif ch in string.ascii_uppercase:
        index = string.ascii_uppercase.index(ch) + ofs
        return string.ascii_uppercase[index % len(string.ascii_uppercase)]

    return ch


passwd = input()
with open('mayun.txt', 'r', encoding='utf-8') as f:
    s = f.read()
    result = [len(re.findall(r'[A-Z]', s)), len(re.findall(r'[a-z]', s)), len(re.findall(r'\d', s)),
              len(re.findall(r'[ \n\t]', s))]
    result.append(len(s) - sum(result))
    offset = sum(list(map(lambda c: ord(c), passwd))) % 26

    print(' '.join('%s' % n for n in result))
    print('共有%d单词' % len(re.findall(r'[a-zA-Z0-9]+', s)))
    print(offset)

    result = []
    for c in list(s):
        result.append(get_kaisa(c, offset))

    print(''.join(result))

身份证号批量升位

# 模板仅供参考,可不按些模板写代码

def id15218(id15):
    ls=[7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2]
    ecc=['1','0','X','9','8','7','6','5','4','3','2']
    sum=0
    j=0
    if int(id15[6:8]) >= 5:
        id17=id15[0:6]+'19'+id15[6:]
    else:
        id17=id15[0:6]+'20'+id15[6:]
    for i in id17:
        sum=sum+int(i)*ls[j]
        j=j+1
    id18=id17+ecc[sum % 11]
    return id18


n = int(input())
with open('id15.txt','r',encoding='utf-8') as file:
    for i in range(n):
        line = file.readline()   # line 的内容是文件中的一行,字符串类型
        line=line.replace(line[0:15],id15218(line[0:15]))
        print(line.strip())

手机销售统计

n = eval(input())

f18 = open('sale2018.csv', 'r', encoding='utf-8')
f19 = open('sale2019.csv', 'r', encoding='utf-8')

l18=list(map(lambda x:x.split(",")[0],f18.read().splitlines()))
l19=list(map(lambda x:x.split(",")[0],f19.read().splitlines()))

l18.sort()
l19.sort()
if n==1:
    print(l19)
    print(l18)
elif n==2:
    result=list(set(l19).intersection(l18))
    print(sorted(result))
elif n==3:
    result=list(set(l19).union(l18))
    print(sorted(result))
elif n==4:
    result=list(set(l19).difference(l18))
    print(sorted(result))
elif n==5:
    result=list(set(l19).difference(l18))
    result.extend(list(set(l18).difference(l19)))
    print(result)

阶段测试一

一道题练会加减乘除和乘方

import math

n1 = input()
n2 = input()
print("{}+{}={}".format(n1, n2, eval(n1) + eval(n2)))
print("{}-{}={}".format(n1, n2, eval(n1) - eval(n2)))
print("{}*{}={}".format(n1, n2, eval(n1) * eval(n2)))
print("{}/{}={:.2f}".format(n1, n2, eval(n1) / eval(n2)))
print("{}除以{}的整数商={}".format(n1, n2, int(eval(n1) / eval(n2))))
print("{}除以{}的余数为={}".format(n1, n2, eval(n1) % eval(n2)))
print("{}的{}次方={}".format(n1, n2, int(math.pow(eval(n1), eval(n2)))))

输入3个数字,由小到大输出

ls=[]
for i in range(3):
    ls.append(int(input()))
ls.sort()
for i in range(len(ls)):
    print(ls[i])

求 n 以内所有奇数的和

sum=0
for i in range(0,int(input())):
    if i%2==0:
        continue
    else:
        sum+=i
print(sum)

奇偶不同,结果不同

n = int(input())
strin = input()
strin2 = ''
for c in strin:
  strin2 = c + strin2
strOut = ""
if n % 2 == 1:
  for i in range(n):
    strOut = strOut + strin + ","
else:
  for i in range(n):
    strOut = strOut + strin2 + ","
print(strOut[:-1])

苹果、李子、橙

# -*- coding:utf-8 -*-
n = int(input())
for i in range(0, n):
    for j in range(0, n):
        for k in range(0, n):
            if ((i * 4 + j * 3 + k / 4 == n) and (i + j + k) == n):
                print("苹果%d只,橙子%d只,李子%d只。"%(i,j,k))

找数字,做加法(升级版)

n1 = input()
n2 = input()
if n1.count('.')>1 or n2.count('.')>1:
  print('输入错误')
else:
  s1,s2 = '', ''
  for c in n1:
    if '0'<=c<='9' or c=='.':
      s1 = s1 + c
  for c in n2:
    if '0'<=c<='9' or c=='.':
      s2 = s2 + c
  print(eval(s1)+eval(s2))

阶段测试二

数字不同数之和

ls=set(input())
sum=0
for i in ls:
    sum+=int(i)
print(sum)

鸡兔同笼B

n = int(input())
for i in range(n):
    feets = int(input())
    if feets % 4 == 0:  # 如果鸡的数量是偶数
        least, most = feets // 4, feets // 2
    elif feets % 2 == 0:  # 如果输入没错
        least, most = (feets - 2) // 4 + 1, feets // 2
    else:  # 如果没有满足答案
        least, most = 0, 0
    print(least, most)

侯先生爬楼梯

def upstrs(n):
    if n==1:
        return 1
    elif n==2:
        return 2
    else:
        return upstrs(n-1)+upstrs(n-2)

n=int(input())
print(upstrs(n))

字符串分段组合

s = input()
ls = s.split("-")
print("{}+{}".format(ls[0], ls[-1]))

编写函数输出自除数

def selfDivisor(num):
    if '0' in str(num):
        return False          # 包含数字0的不是自除数
    for c in str(num):        # 对数字num中的每位数字进行遍历
        if num % int(c) != 0: # 测试num的每一位是否是num的因子
            return False      # 如果存在不能整除的数,则不是自除数
    else:                     # 如果for遍历顺利结束,未遇到return,则执行else子句,返回True
        return True

n=int(input())
for num in range(1,n+1):      # 注意不大于包括等于n
    if selfDivisor(num):      # 调用函数,当返回值为True时,该数为自除数,输出这个数
        print(num,end=' ')    # 输出以空格结尾

103

fi = open("data.txt", 'r')
for l in fi:
    l = l.split(',')
    s = 0.0
    n = len(l)
    for cours in l:
        items  = cours.split(':')
        s += eval(items[1])
    print("总和是:{},平均值是:{:.2f}".format(s,s/n))
fi.close()

文本词频统计 – Hamlet

这个不考

#请在...处补充代码

def getText():
    txt = open("hamlet.txt", "r").read()
    txt = txt.lower()
    for ch in '!"#$%&()*+,-./:;<=>?@[\\]^_‘{|}~':
        txt = txt.replace(ch,"")
    return txt
    
hamletTxt = getText()
words = hamletTxt.split()
counts = {}
for word in words:
    counts[word] = counts.get(word,0)+1
items = list(counts.items())
items.sort(key=lambda x:x[1],reverse=True)
for i in range(10):
    word,count = items[i]
    print(word)

  • 6
    点赞
  • 23
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
以下是Python期末考试的一些重要知识点: 1. Python的基本语法和特点: - Python是一种解释型语言,使用缩进对齐来组织代码执行。 - Python有多种数据类型,包括整型、浮点型、复数、字符串、列表、元组、集合和字典。 - Python中的变量不需要事先声明,可以直接赋值使用。 2. 控制流语句: - 条件语句:使用if、elif和else关键字进行条件判断。 - 循环语句:使用for和while关键字进行循环操作。 3. 函数和模块: - 函数:使用def关键字定义函数,可以接受参数并返回结果。 - 模块:使用import关键字导入其他Python文件中定义的函数和变量。 4. 文件操作: - 打开文件:使用open函数打开文件,并指定打开模式(读取、写入、追加等)。 - 读取文件:使用read、readline或readlines方法读取文件内容。 - 写入文件:使用write方法将数据写入文件。 5. 异常处理: - 使用try和except关键字来捕获和处理异常。 - 可以使用多个except块来处理不同类型的异常。 6. 面向对象编程: - 类和对象:使用class关键字定义类,通过实例化类创建对象。 - 继承和多态:可以通过继承来创建子类,并实现多态性。 7. 内置函数和常用模块: - 内置函数:Python提供了许多内置函数,如print、len、range等。 - 常用模块:Python标准库中包含了许多常用的模块,如math、random、datetime等。 8. 数据结构和算法: - 列表:使用方括号[]来创建列表,可以进行增删改查等操作。 - 字典:使用花括号{}来创建字典,包含键值对,可以通过键来访问值。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值