掌握构造包罗前提语句(if-else)、轮回语句(for、while)等,用于掌握法式的施行过程。
登录后复造
# if-else 语句if age >=18:print("You are an adult.")else:print("You are a minor.")# for 轮回for i inrange(5):print(i)# while 轮回count =0while count <5:print(count) count +=1
登录后复造
defcalculate_area(radius): pi =3.14159return pi * radius * radiusradius =float(input("Enter the radius of the circle: "))area = calculate_area(radius)print(f"The area of the circle is: {area}")
登录后复造
#创立 并写进文献withopen("example.txt","w")asfile:file.write("This is a test file.\nWelcome to Python progra妹妹ing!")# 读与文献实质withopen("example.txt","r")asfile: content =file.read()print(content)