python炒股日记_自学python的日记分享

2019.4.22登记

课堂笔记 2019.4.8

在windows环境下,用python写出第一个程序“hello world”

1 print("Hello World!!!")

View Code

课堂笔记 2019.4.12

在windows环境下,用python写出第一个用户交互程序“input”

1 death_age=120

2

3 print("game star")4 print("")5 print("")6

7 name=input("input your name:")8 age=input("input your age:")9

10

11 print(name,"still able to live",death_age-int(age),"years")

View Code

课堂笔记2019.4.13

python程序: 用户输入3个数字,输出最大的数字和最小的数字

1 #My idea

2

3 '''

4 No1=int(input("please input first number:"))5 No2=int(input("please input scend number:"))6 No3=int(input("please input third number:"))7

8 if No1>No2>No3:9 print("Max No is No1:",No1,"Min No is No3:",No3)10 elif No1>No3>No2:11 print("Max No is No1:",No1,"Min No is No2:",No2)12 elif No2>No1>No3:13 print("Max No is No2:",No2,"Min No is No3:",No3)14 elif No2>No3>No1:15 print("Max No is No2:",No2,"Min No is No1:",No1)16 elif No3>No1>No2:17 print("Max No is No3:",No3,"Min No is No2:",No2)18 elif No3>No2>No1:19 print("Max No is No3:",No3,"Min No is No1:",No1)20 '''

21

22

23 #teather's idea. only MaxNo,no MinNo

24

25 '''

26 No1=int(input("please input first number:"))27 No2=int(input("please input scend number:"))28 No3=int(input("please input third number:"))29

30 No=031

32 if No1>No2:33 No=No134 if No>No3:35 print("Max No is:",No)36 else:37 print("Max No is:",No3)38 else:39 No=No240 if No>No3:41 print("Max No is:",No)42 else:43 print("Max No is:",No3)44 '''

45

46 #bettet idea

47

48 No1=int(input("please input first number:"))49 No2=int(input("please input scend number:"))50 No3=int(input("please input third number:"))51

52 max_No=053 min_No=054

55 if No1>No2:56 max_No=No157 if max_No<58 min_no="No259" print no is: else:61 if no2 else:65 else:68 max_no="No269" else:73 no1 else:77>

View Code

课堂笔记2019.4.14

python的四种运算符:算数运算符,赋值运算符,比较运算符,逻辑运算符。

算数运算符:+,-,*,/,//,%,**

赋值运算符:word="hello"(赋值字符串) , word=23(赋值数字)

比较运算符:,==,!=

逻辑运算符:not , and , or (and和or有短路原则,如果条件1结果已知,后续代码不再执行)

课堂笔记2019.4.15

while语句:打印1-10

1 #打印1=10

2 No = 1

3

4 while No<=10:5 print(No)6 No+=1

View Code

课堂笔记2019.4.16

1.编写一个猜测年龄的程序

1 #猜年轻

2

3 '''用if语句判断4 goal_age=765

6 guess_age=int(input("please guess age(1-100):"))7

8 # print(guess_age,goal_age)9

10 if(guess_age==goal_age):11 print("you got it")12 else:13 print("sorry,you are wrong")14 '''

15

16 #利用while实现一直输入

17 '''

18 暂时无法实现2个问题:19 1.从输错了数字开始算起的区间(比如输入两个数字(34,89)后,无法提醒在(34-89)之间的数字猜测)20 2019.4.22号已自行解决21 2.由用户自己选择放弃猜测退出程序. 2019.5.6 已解决22

23 '''

24 goal_age = 76

25

26 guess_age = int(input("please guess age(1-100):"))27 guess_maxage = 100

28 guess_minage = 1

29

30 while guess_age !=goal_age:31

32 if guess_age < goal_age: #判断输入的数字是否正确

33 print()34 if guess_age > guess_minage: #用来取输入后的最小值

35 guess_minage =guess_age36 print("your input number is:", guess_age)37 print("that's too small... please guess", guess_minage, "-", guess_maxage, "!!")38 elif guess_age >goal_age:39 print()40 if guess_age < guess_maxage: #用来取输入后的最大值

41 guess_maxage =guess_age42 print("your input number is:", guess_age)43 print("that's too big... please guess", guess_minage, "-", guess_maxage, "!!")44

45 guess_age = input("you can input 'give up' go to out or guess again:")46

47 if guess_age == "give up":48 print("It's so pity!!!")49 break

50

51 guess_age =int(guess_age)52

53 else:54 print("you got it")

View Code

2.输出1-100之间的偶数

1 #输入1-100之间的偶数

2

3 No=1

4

5 while No<=100:6 if No%2==0:7 print(No)8 No+=1

View Code

3.语法1:break 用来跳出本循环,continue用来结束本次循环。

语法2:print(“abc”,end=“”) “abc”后面不换行,继续显示打印的内容。

语法3:while ... else... 非break中止的程序,都会执行else后的程序 。

课堂笔记2019.4.19

编写九九乘法表

1 '''

2 个人思路:3 九九乘法表。 a=1 while a <= 9: b=1 while b<=a:print((b,”*”,a,b*a),end(“,”)) b+=1 a+=14 '''

5

6 high =1

7

8 while high<=9:9 wieth=1

10 while wieth<=high:11 print(wieth,"*",high,"=",wieth*high,end="\t") #'\n'是换行,'\t'是tab

12 wieth+=1

13 print()14 high+=1

View Code

58>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值