# print("hello world") # print("hello world") # help("print") # none_data = None # print(none_data, type(none) # test = 'I'm good' # test = '"I`m good"' # print(test, type(test)) # # print(test, type(test)) # # print("\\\\\b") # my_name = input("please input your name:") # print(my_name, type(my_name)) """ 一般字符串 # s = "我叫张**,我今年{}岁,身高{}cm".format(24, 175) # s = "我叫张**,我今年%d岁,身高%fcm" % (18, 175) # age = 18 # high = 175 # s = f"我叫张**,我今年{18}岁,身高{175}cm" # print(s) # s = "123" + str(True) # print(s) # s = "123" + str("abc") # print(s)""" # 特殊字符串 """ 特殊字符串 # binary:二进制字符串 # binary_str = b"1234567890@#*" # # 字符串转为二进制可以用encode str_ = "哈哈哈".encode("BIG")""" # bool类型 """ bool类型 flag = bool("123") print(flag) // True""" """ eval函数计算出结果 count = 3 * 4 +3 print(eval("count"))""" #元组 """ 元组 s = eval(input("请输入一个坐标:"))#注意:输入两个数字时,中间要用逗号隔开 print(s) s = input("请输入一个坐标:")#注意:输入两个数字时,中间要用逗号隔开 print(eval(s)) s1, s2 = eval(input("请输入一个坐标:"))#注意:输入两个数字时,中间要用逗号隔开 print(s1, s2)""" # id函数 """ # id函数 sum = 100 print(id(sum)) sum = sum + 1 print(id(sum)) \\\\\\\\\\\\\\\\\\\\\\\\\ 140728053585432 #内存地址 140728053585464""" # dir : 打印所有模块中的模块,类,属性 """ # dir : 打印所有模块中的模块,类,属性。 import builtins print(dir(builtins))#打印所有函数的模块""" """ s = [1] * 10 print(s) [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]""" """ text = "*" * 100 print(text) /// ****************************************************************************************************""" #实验一:计算圆柱的底面积和高 """ 实验一:计算圆柱的底面积和高 import math r, height = eval(input("请输入两个整数,用逗号隔开:")) area = math.pi * r * r print(area) volume = math.pi * area * height print(volume) D:ython安装包ython.exe D:ython-code存放代码firstprojectmyfirst.py 请输入两个整数,用逗号隔开:1,2 3.141592653589793 19.739208802178716 Process finished with exit code 0""" #实验二:提示用户输入一个数,然后显示颠倒各位数字之后的数 """ num = int(input("请输入一个四位整数:")) gewei = num % 10 shiwei = num % 100 // 10 baiwei = num % 1000 // 100 qianwei = num // 1000 result = gewei * 1000 + shiwei * 100 + baiwei * 10 + qianwei print(result)""" # 三目运算符 """ num1 = 10 num2 = 20 print(num1 if num1 > num2 else num2)""" """ month = int(input("请输入一个人月份:")) if month > 12 or month <= 0: print("请输入正确的月份;") else: if 3 <= month <= 4: print("现在是春天") elif 5 <= month <= 8: print("现在是夏天") elif 9 <= month <= 10: print("秋天") else: print("冬天") """ ''' while循环 num = 0 while num < 10: num += 1 print(num)''' #while循环 '''count = 0 while True: print(count) if count > 100: break count += 1 if count > 50: continue /// 100 101 Process finished with exit code 0''' # 求100以内自然数的和 '''sum = 0 num = 0 while num < 100: num += 1 sum += num print(sum) /// 5050 Process finished with exit code 0''' # for...in..循环 '''array = [1, 2, 3, 4, 5] for n in array: print(n) /// 1 2 3 4 5 Process finished with exit code 0'''
06-23
1765
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
10-13
362
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
12-07
1543
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)