Commit bd3f78ae by BellCodeEditor

auto save

parent c6188a1e
Showing with 110 additions and 4 deletions
s=input("请输入:")#题目要求输入数字串77,56,8,129,102,61,这是个字符串类型,不是int
max=-1#设置一个变量,用来存储最大的数值
i=0#每一个数字起始的位置
j=0#每一个元素开始的位置
while j<len(s):#重复判断变量j是否小于s的长度
ch=s[j]#用j去遍历每一个元素,并赋值给变量ch
if ch==",":#如果ch是元素逗号
tmp=int(s[i:j])#用索引切片取值并转换成整数类型赋值给变量tmp
if tmp>max:#如果变量tmp大于max
max=tmp#就把新的变量值赋值给max
i=j+1#j+1继续判断
j=j+1
tmp=int(s[i:j])
if tmp>max:
max=tmp
print(max)
"""
n=eval(input("请输入数量:"))
if n==1:
cost=150
elif n>=2 and n<=3:
cost=int(n*150*0.9)
elif n>=4 and n<=9:
cost=int(n*150*0.8)
elif n>=10:
cost=int(n*150*0.7)
print("总额为:",cost)
n=eval(input("请输入正整数:"))
print("{0:@>30,}".format(n))
a=[11,3,8]
b=eval(input())
s=0
for i in range(3):
s+=a[i]*b[i]
print(s)
s="abck"
print(eval("s"))
import random
random.seed(255)
for i in range(5):
print(random.randint(1,50),end=" ")
import turtle
turtle.pensize(2)
d=72
for i in range(5):
turtle.seth(d)
d+=72
turtle.fd(200)
turtle.done()
names=input(("请输入各个同学行业名称,行业名称之间用空格间隔(回车结束输入):"))
name_list=names.split(" ")
d={}
for item in name_list:
d[item]=d.get(item,0)+1
ls=list(d.items())
print(d.items())
print(ls)
ls.sort(key=lambda x:x[1],reverse=True)
for k in ls:
print("{}:{}\n".format(k[0],k[1]))
a=3.6e-1
b=4.2e3
print(b-a)
L1=[4,5,6,8].reverse()
print(L1)
try:
print((3+4j)*(3-4j))
except:
print("haha")
def fun(x):
try:
return x*4
except:
return x
import jieba
s = input("请输入一个中文字符串,包含标点符号:")
m =jieba.lcut(s)
print(fun("5"))
print("中文词语数:{}".format(len(m)))
def fun(b=2,a=4):
global z
z+=3*a+5*b
return z
z=10
print(z,fun(4,2))
"""
ls=[]
for m in "想念":
for n in "家人":
ls.append(m+n)
print(ls)
import pygame
from pygame import locals
# 初始化pygame,为使用pygame做准备
pygame.init()
background=pygame.image.load("bg.png")
right=pygame.image.load("right.png")
food=pygame.image.load("apple.png")
# 创建一个窗口
??
\ No newline at end of file
screen=pygame.display.set_mode((660,480))
while True:
for event in pygame.event.get():
if event.type==locals.QUIT:
exit()
screen.blit(background,(0,0))
screen.blit(right,(240,120))
screen.blit(food,(360,300))
pygame.display.update()
\ No newline at end of file
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