<jupyter_start><jupyter_text>基本程序设计- 一切代码输入，请使用英文输入法<jupyter_code>print("hello word")<jupyter_output>hello word<jupyter_text>编写一个简单的程序- 圆公式面积： area = radius \* radius \* 3.1415<jupyter_code>bianchang = eval( input('>>'))  
area = bianchang * bianchang
print (area)<jupyter_output>>>10
100<jupyter_text>//eval 输入时自动转化成需要的类型  在Python里面不需要定义数据的类型  控制台的读取与输入- input 输入进去的是字符串- eval - 在jupyter用shift + tab 键可以跳出解释文档  变量命名的规范- 由字母、数字、下划线构成- 不能以数字开头 \*- 标识符不能是关键词(实际上是可以强制改变的，但是对于代码规范而言是极其不适合)- 可以是任意长度- 驼峰式命名  变量、赋值语句和赋值表达式- 变量: 通俗理解为可以变化的量- x = 2 \* x + 1 在数学中是一个方程，而在语言中它是一个表达式- test = test + 1 \* 变量在赋值之前必须有值<jupyter_code>radius = eval (input('>>'))
radius = radius + radius
print(radius)<jupyter_output>>>10
20<jupyter_text>同时赋值var1, var2,var3... = exp1,exp2,exp3...<jupyter_code>小明 = '男';小猫='女'
小明 = '男'
print(小明)<jupyter_output>男<jupyter_text>定义常量- 常量：表示一种定值标识符，适合于多次使用的场景。比如PI- 注意：在其他低级语言中如果定义了常量，那么，该常量是不可以被改变的，但是在Python中一切皆对象，常量也是可以被改变的<jupyter_code>height,width=<jupyter_output><empty_output><jupyter_text>数值数据类型和运算符- 在Python中有两种数值类型（int 和 float）适用于加减乘除、模、幂次  运算符 /、//、**<jupyter_code>10 / 10
10 // 10
10**2<jupyter_output><empty_output><jupyter_text>运算符 %  EP：- 25/4 多少，如果要将其转变为整数该怎么改写- 输入一个数字判断是奇数还是偶数- 进阶: 输入一个秒数，写一个程序将其转换成分和秒：例如500秒等于8分20秒- 进阶: 如果今天是星期六，那么10天以后是星期几？ 提示：每个星期的第0天是星期天<jupyter_code>(25//4)
a = eval (input('输入一个数'))
if  (a % 2 == 0):
    print(str(a)+'是一个偶数')
else :
    print(str(a)+'是一个奇数')
    
miao = eval(input('输入一个秒数'))
fen = miao// 60
miao_ = miao% 60
print(str(fen)+'分'+str(miao_)+'秒')

weekend = eval (input('>>'))
res = (weekend + 10) %7
print(str(weekend)+'在10之后是星期'+str(res))<jupyter_output>>>1
1在10之后是星期4<jupyter_text>科学计数法- 1.234e+2- 1.234e-2<jupyter_code>x = 10
y = 6
a = 0
b = 1
c = 1
p1 = (3 + 4*x)
p2 = p1/5

p3 = y - 5
p4 = a+b+c
p5 = 10*p3*p4

p6= 4/<jupyter_output><empty_output><jupyter_text>计算表达式和运算优先级<jupyter_code>x = 10
y = 6
a = 0
b = 1
c = 1

p = ((3+4*x)/5) - (10*(y-5)*(a+b+c)/x) + (9*((4/x)+((9+x)/y)))
print(p)
x = 10
y = 6
a = 0
b = 1
c = 1
p1 = (3 + 4*x/5)

p2 = ((10*(y - 5 )*(a+b+c))/x)

p3 = (9*((4/x)+((9+x)/y)))

p = p1 - p2 + p3 
print (p)<jupyter_output>41.099999999999994<jupyter_text>增强型赋值运算<jupyter_code>a=1 
a += 1
a<jupyter_output><empty_output><jupyter_text>类型转换- float  -> int- 四舍五入 round<jupyter_code>round(3.141592,2) #要四舍五入的值，第二个保留值位数<jupyter_output><empty_output><jupyter_text>EP:- 如果一个年营业税为0.06%，那么对于197.55e+2的年收入，需要交税为多少？(结果保留2为小数)- 必须使用科学计数法<jupyter_code>p=197.55e+2 * 6e-4
round(p,2)<jupyter_output><empty_output><jupyter_text>Project- 用Python写一个贷款计算器程序：输入的是月供(monthlyPayment) 输出的是总还款数(totalpayment)![](../Photo/05.png)  Homework- 1<jupyter_code>celsius = eval(input('Enter a degree in Celsius:'))
fahrenheit = (9 / 5) * celsius + 32
print(str(celsius) + ' Celsius is' + ' '+str(fahrenheit) + ' Fahrenheit')<jupyter_output>Enter a degree in Celsius:43
43 Celsius is 109.4 Fahrenheit<jupyter_text>- 2<jupyter_code>radius,length = eval(input('Enter the radius and length of a cylinder:'))
area = radius * radius * 3.14
volume = area * length
print('The area is area'+str(area))
print('The volume is '+str(volume))<jupyter_output>Enter the radius and length of a cylinder:5.5,12
The area is area94.985
The volume is 1139.82<jupyter_text>- 3<jupyter_code>mun = eval(input('Enter a value for feet:'))
mi =   mun * 0.305
print(str(mun)+'feet is '+str(mi)+' meters')<jupyter_output>Enter a value for feet:16.5
16.5feet is 5.0325meters<jupyter_text>- 4<jupyter_code>M = eval(input('Enter the amount of water in kilograms:'))
initialTemperature= eval(input('Enter the initial temperature:'))
finalTemperature = eval(input('Enter the final temperature:'))
Q = M * (finalTemperature - initialTemperature) * 4184
print('The energy neede is '+ str(Q))<jupyter_output>Enter the amount of water in kilograms:55.5
Enter the initial temperature:3.5
Enter the final temperature:10.5
The energy neede is 1625484.0<jupyter_text>- 5<jupyter_code>chae,nianlilv = eval(input('Enter balance and interest rate (e.g.,3 for 3%):'))
lixi =round((chae * (nianlilv/1200)),5)
print('The interest is '+str(lixi))<jupyter_output>Enter balance and interest rate (e.g.,3 for 3%):1000,3.5
The interest is 2.91667<jupyter_text>- 6<jupyter_code>v0,v1,t = eval(input('请输入以米为单位的初始速度V0和末速度v1和以秒单位速度变化所占用时间t：'))
a = round(((v1-v0) / t) ,4)
print('The average acceleration is '+ str(a))<jupyter_output>请输入以米为单位的初始速度V0和末速度v1和以秒单位速度变化所占用时间t：5.5,50.9,4.5
The average acceleration is 10.0889<jupyter_text>- 7 进阶<jupyter_code>amount = eval(input('Enter the monthly saving amount:'))
sum = 0
i = 0
for num in range (0,6):
    sum = (amount + sum ) * (1+0.00417)
    i +=1
print('After the sixth month ,the account value is '+str(round(sum,2)))<jupyter_output>Enter the monthly saving amount:100
After the sixth month ,the account value is 608.82<jupyter_text>- 8 进阶<jupyter_code>mun = eval(input('Enter a number between 0 and 1000:'))
ge = mun % 10
shi = mun //10
shiwei = shi % 10
bai = mun // 100
sum = ge + shiwei + bai
print('The sum of the digits is :'+ str(sum))<jupyter_output>Enter a number between 0 and 1000:100
The sum of the digits is :1
{'fraction_non_alphanumeric': 0.16164599330576884, 'fraction_numerical': 0.06713920063004529, 'mean_word_length': 5.9021739130434785, 'pattern_counts': {'":': 0, '<': 67, '<?xml version=': 0, '>': 80, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 1, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '20', 'dir': 'jupyter-structured-clean-dedup', 'id': '611993', 'license': 'Apache-2.0', 'n_tokens_mistral': 2824, 'n_tokens_neox': 2732, 'n_words': 447, 'path': '7.16.ipynb', 'repo_name': 'Zhangzzt/mode', 'size': '5079'}