python--01day

print('Hello world')

# Single line omitted

"" "" "" Multiple lines omitted

NOTE: When administered 6 quotes variables, i.e., into the string

 

sed ( '') to output what division

end ( '') to the output end of what

 

Print ( ' {} you're ugly ' .format (INPUT ())) 
input Hu Wang
output Hu Wang you're ugly

 

ord (): ASCII string into

chr (): the opposite

Examples to the mailbox encryption

email = input('Input Your Email:')
for i in email:
    #拿出当前的ASCII
    chr_ = ord(i) + 4
    ord_ = chr(chr_) 
    print(ord_,end = "")



Input Your Email:4562311dasd
89:6755hewh

 

 

Examples Celsius and Fahrenheit conversion

Import Math 
R & lt = a float (INPUT ( ' Enter radius of the circle: ' )) 
P = 2 * * Math.PI R & lt 
Area = R & lt Math.PI * * R & lt 
 Print ( ' circumference:.%. 2F ' % P)
 Print ( ' area:.%. 2F ' % area) 


Please enter the radius of the circle: 55 
perimeter: 345.58 
area: 9503.32

 

 

Examples determine whether it is a leap year

int = Y (INPUT ( ' Enter year: ' ))
 IF (Y%. 4 == 0 and Y 0 = 100%! or \ 
           Y % 400 == 0):
     Print ( ' leap ' )
 the else :
     Print ( ' average year ' ) 


Please enter Year: 2222 
leap year

 

 

Some examples to determine which number is a number between 100 to 1000 daffodils

or n in range(100,1000):
        f = int((n / 100))
        s = int(n / 10) % 10
        t = n % 10
        if  n == f ** 3 + s ** 3 + t ** 3:
            print(n)


153
370
371
407

 

 

Output example a square

for i in range(10):
    print('.',end=" ")
print()
for k in range(8):
     print('.',' '*16,' .',sep="")

for i in range(10):
    print('.',end=" ")



. . . . . . . . . . 
.                 .
.                 .
.                 .
.                 .
.                 .
.                 .
.                 .
.                 .
. . . . . . . . . . 

 

Self-study

Adding the number of consecutive two input separated by commas

a,b = map(int,input().split('*'))
print(a+b)


5,6
11

Enter the number of consecutive three    

Example write a program that prompts the user to enter one meter per second in units of initial velocity v0 and the terminal velocity v1, the rate of change in seconds occupied time t, and then displays the average acceleration

v0,v1,t = eval(input('Enter v0, v1 and t:'))
a = (v1 - v0)/t
print('The average acceleration is %.4f' % a)


Enter v0, v1 and t:5.5,50.9,4.5
The average acceleration is 10.0889

 

Guess you like

Origin www.cnblogs.com/cnxy168/p/11272527.html