Parisgabriel:python Endless day03

Source: Internet
Author: User

Parisgabriel

basics of getting started with Python 

print ("Hello World")
variables: Stored information, later called, modified Operation
constants: Fixed amounts, uppercase letters
naming rules:
1. Alphanumeric Underline composition
2. Cannot start with a number, cannot contain special characters and spaces
3. Cannot be named with a reserved word
4. Cannot be named in Chinese
5. The variable name defined should make sense
6. Hump-Type life, underline word segmentation
7. Variable names are case-sensitive
a=1
b=2
if a<b:
print ("Yes")
print ("Yes")
print ("Yes")
print ("Yes")
Else:
print ("No")
a=1
b=2

If a>b:
Print ("Yes")

Elif a==b:
Print ("third")

Else
Print ("any")


If condition 1:
Self -
Elif Condition 2:
Jumped
Else
Dance


# single Comment
"Multi-line Comment"
"" "Multiline Comment" ""


Input ()


"ABC" + "Qwe"

file.py
Extension of File:
. Py:python Program Files
. txt: Text file
PDF CHM HTML doc XML xls ppt


JPG png gif jpeg BMP
Avi RMVB MP4 mkv 3gp
WMV MP3 Flue mid

True is true right
False false Error


A
b = 100
c = 1000

If b <= a <= c:
Print ("True")

Num number

NUM1 = INTPU ("NUM1:")
num2 = INTPU ("Num2:")
num3 = INTPU ("Num3:")

Outputs the maximum/minimum value in three digits

If num1>num2>num3:
#num1最大

Else
#num1 <num2

If Num1>num2>num3 #num1最大
Elif num1>num3>num2 #num1最大
Elif num2>num1>num3 #num2最大
Elif Num2>num3>num1 #num2最大
Elif Num3>num2>num1 #num3最大
Else

Num3>num1>num2 #num3最大

NUM1 num2 num3

max_num =0

if num1>num2:
max_num= num1
if max_num > num3:
print ("Max NUM is", max_num)
else:
print ("Max NUM is", num3)
else:
Max_num = num2
if Max_num > num3:
print ("Max NUM is", max_num)
else:
print ("Max NUM is", num3)


num + = 1 is equivalent to num = num + 1
num-= 1 is equivalent to num = num-1
Num *= 2 equivalent to num = num * 2
Num/= 2 is equivalent to num = NUM/2
Num//= 2 equivalent to num = num//2
Num%= 2 equivalent to num = num% 2
Num **= 2 equivalent to num = num * * 2


And, and
Only if two conditions are all true (correct), the result will be true (correct)


Condition 1 and Condition 2
5>3 and 6<2 True


or OR, or
As long as there is a condition of true, the result is ture,
5>3 or 6<2
True or False

Not no, ya minute fly butterfly

Not 5>3 = = False
Not 5<3 = = True


A>b and (c>d or (not f))


(Not-true) or (False and (not true))


Condition 1 and Condition 2
Condition 1 or Condition 2
Short Circuit principle
For and if the first condition in front is false, then the expression of the two conditions of the and before and after will be calculated as false, and the second condition will not be computed

For or
If the first condition above is true, then the result of an expression consisting of or before or after two conditions must be true, and the second condition will not be computed

True or True and False


Guess age

Age = 50

user_input_age = Int (input ("Age is:"))

If ....

While loop


While condition:
Print ("any")
Print ("any")


num = 1

While num<10: # 2
Print (num) # 2
Num+=1 # 3
if num = = 9: # 3
Break

num = 1

While num<=100: # num<=100 equivalent to True
# while num<=100: equivalent to while True:
If num%2 = = 0:
Print (num)
num + = 1


num = 1

While num<=100:
if num%2 = = 1:
Print (num)
num + = 1



Age = 50

#user_input_age = Int (input ("Age is:"))

Flag = True

While flag:
user_input_age = Int (input ("Age is:"))
if user_input_age = = Age:
Print ("Yes")
Flag =false
Elif user_input_age > Age:
Print ("is bigger")
Else
Print ("is smaller")


Print ("End")

Break # Terminate
Age = 50

#user_input_age = Int (input ("Age is:"))

#flag = True
# break
While True:
user_input_age = Int (input ("Age is:"))
if user_input_age = = Age:
Print ("Yes")
Break
Elif user_input_age > Age:
Print ("is bigger")
Else
Print ("is smaller")


Print ("End")

Continue continue


If A>b and D<f or 5>3 and d = = e:
......


While condition:
....
Else
....

Statement statements


num = 1
While Num <= 10:
num + = 1
if num = = 5:
Break
Print (num)
Else
Print ("This is Else statement")

While condition 1:
.....
While condition 2:
....



1*1=1
1*2=2 2*2=4
1*3=3 2*3=6 3*3=9
....


#print ("Hello World", end= "__") # \ r \ n \ r
#print ("Hello World", end= "__")
#print ("Hello World", end= "__")

NUM1 = 0

While num1<=5:
Print (num1,end= "_")
num2 = 0
While num2<=7:
Print (num2,end= "-")
Num2+=1

Num1+=1
Print () # print (end= "\ n")

#0_0 -1-2-3-4-5-6-7-
#1_0 -1-2-3-4-5-6-7-


Height altitude
Width widths

height = Int (input ("Height:")) # user enters a height
width = Int (input ("width:")) # user enters a width

Num_height = 1
While Num_height <=height:
Num_width = 1
While Num_width <= width:
Print ("#", end= "")
Num_width + = 1
Print ()
Num_height + = 1


12345678
22345678
32345678
42345678

The first line of time 8 characters 8 cycles
The second line of time 8 characters 8 cycles
The third line of time 8 characters 8 cycles
8 characters 8 cycles in line four


width = Int (input ("width:"))

Num_width = 1

While Num_width<=width:
Print ("#", end= "")
Num_width +=1
Print ()

Num_width = 1
While Num_width<=width:
Print ("#", end= "")
Num_width +=1
Print ()

Num_width = 1
While Num_width<=width:
Print ("#", end= "")
Num_width +=1
Print ()

Num_width = 1
While Num_width<=width:
Print ("#", end= "")
Num_width +=1









#print ("#", end= "")
#print ("#", end= "")
#print ("#", end= "")
#print ("#", end= "")

Print ()

num = 4
While num>0:
Print ("#", end= "")
num-= 1
Print ()

# @ == ####




height = Int (input ("Height:")) # user enters a height
width = Int (input ("width:")) # user enters a width

#num2 = height

num2 = height # first step: Assignment
While num2 > 0: # Step two: num2 = = 2

NUM1 = width # step Three: Assign a value
While Num1>0: # Fourth: num1==2 # Seventh Step: NUM1 = 1
Print ("#", End= "") # Fifth Step: Do not wrap a # eighth step: Print a # without a line break
NUM1-= 1 #第六步: NUM1 = 1 Nineth step: num1 = 0
Print () # Tenth step: Just a newline
Num2-= 1 # 11th step: num2=1

##
##

Print ("1*1=", 1)

# "1*1=", 1 = = str (m) + "*" +str (n) + "=", 1


m = 2
n = 2

Print (str (m) + "*" + STR (n) + "=", M*n)



line = 5 # First step: Assign Value
While line>0: # Part Two line=5

TMP = line # Part III: TMP =5 tmp=4

While Tmp>0: # Fourth: tmp =5 #第七步 tmp=4 #第十部: tmp=3 13th step tmp=2
Print ("*", end= "") #第五步 #第八部 #第十一部 #第十四步
TMP = tmp-1 # sixth Step tmp = 4 # nineth Step tmp=3 # 12th Step tmp=2 15th Step tmp= 1

Print ()
#print (line)
Line-= 1


First = 1
While first<=9:

SEC = 1
While SEC <= First:
Print (str (SEC) + "*" + str (FIRST) + "=" +str (sec * first), end= "\ T")
SEC + = 1


Print ()


First + = 1



It's too late today to class tomorrow night to fill the picture code

Parisgabriel:python Endless day03

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.