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 St and for operand, * stand for operator), expressions can get value, so put them on the right of ' = ' to assign value to a VE Riable.
Thirdly, I mastered the usage of while loop, so I spent the whole afternoon going about doing it.
The first program I writed (what 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 ("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 ("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-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 the-the-the-Python Day 3