# print("Hello python")## print("a")def Hello():return print("Hello python")Hello()def fahrenheit(celsius):celsius_a =celsius * 1.8 + 32return str(celsius_a)+'F'result = fahrenheit(90)print(result)def weight (wei):wei1= wei*1000return str(wei1)+'g'wei2= weight(3)print(wei2)def fun_c1(a,b):c=a**2+b**2return ca=fun_c1(3,4)print(a)import math # 导入 math 模块用于 sqrt(平方根)def hypotenuse(a, b):"""计算直角三角形的斜边"""c = math.sqrt(a**2 + b**2) # 勾股定理return f"三角形的斜边是 {c}" # 返回格式化字符串# 测试print(hypotenuse(a=3,b=4)) # 输出:三角形的斜边是 5.0print(hypotenuse(5, 12)) # 输出:三角形的斜边是 13.0print(' *',' **',' ***',' |',sep='\n')# file = open('C://Users/1/Desktop/test.txt','w')# file.write('Hello python')# def txt_creat(name,msg):# desktop_path ='//Users/1/Desktop' #桌面的路径# full_path = desktop_path+name+'.txt' #文件名设定# file = open(full_path,'w') #文件打开指令,填写为写# file.write(msg) #文件写入# file.close() #文件关闭# print('Done')## txt_creat('Tcreat','Helll')#在桌面上创建一个txt文件,需要注意更改,# import os## def txt_creat(name, msg):# desktop_path = os.path.join(os.path.expanduser('~'), 'Desktop') # 动态获取桌面路径# full_path = os.path.join(desktop_path, f"{name}.txt") # 安全拼接路径## try:# with open(full_path, 'w', encoding='utf-8') as file:# file.write(msg)# print(f'文件创建成功:{full_path}')# except FileNotFoundError:# print("错误:桌面路径不存在,请检查用户名!")# except PermissionError:# print("错误:权限不足!")#Creat ten File folder# a=1# while a<11:# txt_creat(a, 'Hello This is My Frist Python Program!')# a = a+1# 测试# txt_creat('Tcreat', 'Hello This is My Frist Python Program!')#可以编写过滤器等# def txt_filter (word,censored_word='lame',changed_word = 'Awesome'):# return word.replace(censored_word,changed_word)## a = txt_filter('Python is lame')# print(a)# if 1>1:# print('ture')# else:# print('false')#实现比对输入密码,如果不对则一直会卡在这里,直到输入正确# def login ():# password = input('Password:')# if password == '123456':# print('Password is ok')# else:# print('Wrong password')# login()# login()# a= int(input('a:'))# if a>10:# print('a>10')## elif a==10:# print('a=10')# else:# print('a<10')# PassWordList = ['Hello','1230','123456']## print(PassWordList[-1])#Reset Password# PassWordList = ['*#*#','456789']## def Login():# intput_data = input('Place input password:')# password_corrent = PassWordList[-1]# password_set = PassWordList[0]## if intput_data == password_corrent:# print('Login success')## elif intput_data == password_set:# new_passwprd = input('Place input newpassword:')# intput_data = new_passwprd# Login()## elif intput_data != password_corrent:# print('Password error,Place input again')# Login()#For Loop# for Helle in 'Hello python':# print(Helle)#Loop & if# song_list = ['A','B','C','D']# for loop_char in song_list :# if loop_char == 'A':# print("This is A")# elif loop_char == 'B':# print("This is B")# elif loop_char == 'C':# print("This is C")# elif loop_char == 'D':# print("This is D")# infinite Loop# while Ture# do sonmething#直到条件不满足时就会退出循环#Printf all of the evenNum in 100# def show_evenNum():# a = 0# while a<=100:# if a%2==0:# print(a)# a=a+1# show_evenNum()# #import random 引入其他库# import random### def ui_show():# print("<<<<<<< program start! >>>>>>>>>>>")# intput_data = input('Place intput Big or Small?')# return intput_data### def logic_strat():# point0 = random.randrange(1, 7)# point1 = random.randrange(1, 7)# point2 = random.randrange(1, 7)## #print(point0, point1, point2)# a_list = [point0, point1, point2]# # print(sum(a_list))# return a_list## def game_start():# sum_list = logic_strat()# sum_data =sum(sum_list)# print(sum_data)# input_data_g = ui_show()# if(11<=sum_data and input_data_g =='Big'):# print('It is Big,you are win!')## else:# print('It is Small,you are LOSE!')# game_start()
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。