PythonDay_01

1. acquaintance Python

Python history

1) Christmas 1989: Guido von Rossum began to write a compiler Python language.

2) February 1991: First Python compiler (also interpreter) was born, it is implemented in C language

3) January 1994: Python 1.0 released

4) October 16, 2000: Python 2.0 release, Python entire development process more transparent

5) 2008 December 3: Python 3.0 release, it is not fully compatible with previous Python code

pethon2.7 2020 will stop maintenance, will usher in the era of pethon3.0

2. Python applications

Python is currently in the field of cloud infrastructure, DevOps, web crawler development, data analysis, mining, machine learning, etc. have a wide range of applications, and therefore also had a back-end Web development, data interface development, operation and maintenance of automation, automated testing, and scientific computing visualization, data analysis, quantitative trading, robot development, a series of image recognition and processing jobs.

3. Run the Python program in Jupter

First Python Program - hellow world

print('hello world')

 

5. Python language structure

Variables and types

Shaping: 1) python 2.x integer int and there are two types of long

   2) Due to the long int distinction has little significance for Python, python 3.x only one kind of int

Float: Float is the presence of a decimal point, and decimal places variable, floating point representation available LCyT

String: 1), also known as char, char can be used single or double quotes surround

     2) "" "123 412" "" multi-line comment (when six quotes given variable, that is a string)

Boolean: True and includes only Boolean False, the calculation in Python and none 0 to False,. 1 and 0 and none except any character or number are True

Complex-type: the form `3 + 5j`, expressed with the same mathematical complex, the only difference is the imaginary part of the` i` replaced `j`

Variable naming

1) Variable names consist of letters (generalized Unicode characters, not including special characters), numbers, and the underscore, numbers can not begin with

2) case-sensitive (uppercase and lowercase `a`` A` are two different variables)

3) Do not tell keywords (words that have special meaning) and system reserved words (such as the name of the function, modules, etc.) conflict

4) to a variable named time as far as possible see the name EENOW

Use variables

Performing an arithmetic operation using the variable

a=input()
a=int(a)
c=input()
b=input()
b=int(b)
if(c=='+'):
    print(a+b,end="")
if(c=='-'):
    print(a-b,end="")
if(c=='/'):
    print(a/b,end="")
if(c=='*'):
    print(a*b,end="")

Using the input function input

Using int () type conversion

Note:

- int (): converts a string or an integer value, can be specified band.
- float (): converts a string to float.
- str (): The specified object is converted into a string, the encoding can be specified.
- chr (): to convert the integer to a character string (a character) corresponding to the code.
- ord (): The character string (a character) into corresponding encoded (integer)

Operators Python

| Operator | described | 
| ------------------------------------------- ----------------- | ------------------------------ | 
| `[]` `[:] ` | subscript, slice | 
| `` ** | index | 
| `~` `` `-` + | bitwise, sign | 
| *` `` / ` `%` `//` | multiply, divide, die, divisible | 
| `+` `-` | plus, minus |  
|` `<< >>` `| right, left |
| &` `| bitwise aND | 
| `^` `|` | bitwise exclusive OR, bitwise or | 
| `<=` `<` `>` `> =` | is less than equal to, less than, greater than, greater than equal to | 
| `` == `` = |! equal, not equal | 
| `` is` IS not` | identity of the operator | 
| `` in` not in` | member operator | 
| not` `` OR ' `and` | logical operators | 
| =` `` `` + = - = = * `` `` / ``% = = = // `` `` `` ** = & = `` | `= `^ =` `>> =` `<< =` | ( composite) assignment operator       

Python practice

Email Encryption

email=input("Input Young Email:")
for i in email:
    res = ord(i)+4
    red = chr(res)
    print(red,end="")

Celsius Fahrenheit turn

INPUT = F. ( " Input Fahrenheit: " ) 
F. = A float (F.) 
C = (32-F.) /1.8
 Print ( ' {} {} = degrees Fahrenheit ' .format (F., C))

Enter the radius of the circle the perimeter and area requirements of the park

INPUT = R & lt ( " Please enter the circle of radius R & lt: " ) 
R & lt = a float (R & lt) 
C = 2 * 3.14 * R & lt 
S = 3.14 * R & lt * R & lt
 Print ( " circumference: " , C)
 Print ( " area : " , S)
 Print ( ' circumference is:% f, the area is: F% ' % (C, S))

Determine whether a leap year

INPUT = year ( " Please enter the year: " ) 
year = int (year)
 IF ((== 0. 4% year and year 100% = 0)! or (400% year == 0)):
     Print ( ' {} is a leap year ' .format (year))
 the else :
     Print ( ' {} is not a leap year ' .format (year))

Numbers by daffodils

Number = INPUT ( ' Enter a number ' )
 IF len (Number)>. 3 :
     Print ( ' ! of The Number IS to Big ' )
 the else : 
    Bai = int (Number [0]) 
    Shi = int (Number [. 1 ]) 
    GE int = (number [2 ])
     IF Bai Shi ** + **. 3 3+. 3 ** GE == int (number):
         Print ( ' number daffodils ' )
     the else :
         Print ( ' not narcissistic number ' )

Draw a rectangle using the Python

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

 

 

Guess you like

Origin www.cnblogs.com/lzqitdl/p/11272662.html
01
01-