Commit 6523013a by BellCodeEditor

save project

parent 6fb0524b
a=int(input("请输入A:"))
import random
a=int(input("请输入A:"))
b=int(input("请输入B:"))
c=int(input("请输入C:"))
D=(a+b)*c
print(D)
import random
a=[]
for i in range(10):
a.append(random. randint(1,99))
print(a)
print(max(a))
\ No newline at end of file
-- "a/\345\234\206.py"
c=input("请输入一个字符:") 身份
c=input("请输入一个字符:") 身份
f=int(input("请输入金额:"))
e=0
if c=="d":
e=f*0.7
elif c=="g":
e=f*0.8
elif c=="h":
e=f*0.9
elif c=="i":
e=f*0.95
print(e)
def hello(name):
class Hero:
def hello(name):
content="你好!"+name
return content
result=hello("小依")
print(result)
\ No newline at end of file
class Hero:
def __init__(self,name,hp,attack):
self.level=1
self.name=name
self.hp=hp
self.attack=attack
yase=Hero("亚瑟",300,20)
houyi=Hero("后羿",240,27)
print("亚瑟的血量为:",yase.hp)
print("后羿的血量为:",houyi.hp)
def upgrade():
yase.level=yase.level+1
yase.hp=yase.hp+50
yase.attack=yase.attack+5
lubu=Hero("吕布",320,20)
print("吕布的血量为:",lubu.hp)
\ No newline at end of file
A=int(input("a"))
with open(r"C:\Users\lenovo\Desktop\Yui.txt",'r',encoding='utf-8')as file:
A=int(input("a"))
if A>0:
print("positive")
if A=0:
print("zero")
if A<0:
print("negative")
\ No newline at end of file
with open(r"C:\Users\lenovo\Desktop\Yui.txt",'r',encoding='utf-8')as file:
a=file.readlines()
final_sum=[]
for i in a:
data=i.split()
sum=0
for sales in data[1:]:
sum=sum+int(sales)
result=data[0]+str(sum)+'\n'
final_sum.append(result)
with open(r"C:\Users\lenovo\Desktop\Yui.txt",'w',encoding='utf-8')as file:
file.writelines(final_sum)
new_date=''
new_data=''
new_date=''
filel=open(r"C:\Users\lenovo\Desktop\xxxx.txt",'w',encoding='utf-8')
filel.write('小强:10本\n')
filel.write('李明:15本\n')
filel.write('小兰:12本\n')
for date in filel:
if '小强:10本'in a:
date=date.replace('小强:10本','小强:11本' )
print("在文件中")
filel.close()
new_data=''
with open(r"C:\Users\lenovo\Desktop\xxxx1.txt",'w',encoding='utf-8')as file1:
file1.write('小强:10本')
with open(r"C:\Users\lenovo\Desktop\xxxx1.txt",'r',encoding='utf-8')as file1:
for data in file1:
if '小强:10本' in data:
data=data.replace('小强:10本','小强:11本' )
new_data+=data
with open(r"C:\Users\lenovo\Desktop\xxxx1.txt",'w',encoding='utf-8')as file1:
file1.write(new_data)
#with open(r"C:\Users\lenovo\Desktop\xxxx.txt",'a',encoding='utf-8') as file:
#file.write('小兰:12本\n')
......
for i in range(4):
for i in range(4):
......@@ -4,4 +4,5 @@ for i in range(4):
for k in range(4 - i, 4):
print("x", end=" ")
print("")
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment