the Way of Python Day 3
Posted margin1314
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了the Way of Python Day 3相关的知识,希望对你有一定的参考价值。
today,i learned so much knowledge about the basis of python.
firstly,i studied methematical operators like ‘+‘,‘/‘ and so on.
for instance,2*3=5 , 4/2=2.0 and so on.
And, i also knew about comparison operators like ‘>‘,‘<=‘,‘==‘ and the rest.
for exmple,2 < 3,2 <=3,3==3 and the rest.
afterwards,i mastered assigning operators like ‘=‘,‘+=‘,‘**=‘ etc.
in the end of morning,i grasped the usage of logical operator,and、or、not.
secondly,i knew a expression is a statement or code consisting of operands and operators ,like 1 * 3 * 4(1、3、4 stand for operand ,* stand for operator ),expressions can get value ,so put them on the right of "=" to assign value to a veriable.
thirdly,i mastered the usage of while loop ,so i spent the whole afternoon going about doing it.
the first program i writed(how to get odd number and even number):
num = 1
while num <= 100:
if num%2 == 0 :
print(num)
num += 1
and
num = 1
while num <= 100 :
if num%2 != 0 :
print(num)
num += 1
a program of guessing age:
age = 50
user_input_age = int(input("age is : "))
while user_input_age != age :
if user_input_age == age :
print("yes")
elif user_input_age > age :
print("bigger")
else :
print("smaller")
user_input_age = int(input("age is : "))
print("End")
or
age = 51
flag = True
while flag :
users_age = int(input("Age is "))
if users_age == age:
print("yes")
flag = False
elif users_age > age:
print("bigger")
else :
print("smaller")
print("End")
or(and the usage of ‘break‘)
age = 51
while True :
users_age = int(input("Age is "))
if users_age == age:
print("yes")
break
elif users_age > age:
print("bigger")
else :
print("smaller")
print("End")
and
num = 1
while num<10 :
print(num)
num += 1
if num == 3 :
break
a program of using # to get a rectangle :
num_height = 1
height = int(input("Please input the height of the retangle: "))
width = int(input("Please input the width of the retangle:"))
while num_height <= height :
num_width = 1
while num_width <= width :
print("#",end="")
num_width += 1
num_height += 1
print()
a way to get the multiplication table:
first = 1
while first <= 9 :
third = first
second = 1
while second <= third :
print(str(second)+"*"+str(third)+"="+str(second*third),end="\t")
second += 1
print()
first += 1
以上是关于the Way of Python Day 3的主要内容,如果未能解决你的问题,请参考以下文章
reviews of learn python3 the hard way
Python on the Way, Day1 - Python基础1
the way of reading English books
learn python the hard way 习题6~10总结
Introducing Custom API – The New Way of Creating Custom Actions in Dataverse