The first week learning Python 7-30

1, start IPython method: In the cmd by IPython IPython ipython command to start the command line or in the knock jupyter-notebook cmd command, and then get the URL login with a browser, open the web interface

2, comments in the code: single-line comments - in section and leading space #

                                Multi-line comments - three at the beginning of quotation marks, three closing quotes

3, variables and types: integer (int), float (a float), string (char), Boolean (Boolean, Boolean values ​​true and false only two kinds)

4, variable usage:

input: Input Function

type (): variable of type checking

int (): or a string to an integer value, can be specified hexadecimal

float (): converts a string to float

str (): converts a string developed into objects, you can specify the encoding

chr (): to convert into an integer corresponding to the code string (a character)

ord (): The character string (a character) into a pair of code (an integer)

Example:

 

5, the operator:

Operators description
[][:] Subscript, sliced
** index
~+- Bitwise, sign
*/%// Multiply, divide, die, divisible
+- Addition, subtraction
>><< Right, left
& Bitwise AND
^| Bitwise XOR Bitwise or
<=<>>= Less than or equal, less than, greater than, greater than or equal
==!= Equal, not equal
isis not Identity operator
innot in Member operator
notorand Logical Operators
=+=-=*=/=%=//=**=&=|=^=>>=<<= (Composite) assignment operator

6, exercise programming code in class

Exercise 1: Celsius Fahrenheit turn

Exercise II: Enter radius of the circle circumference and area calculation

Exercise Three: Enter the year is not a leap year judgment

Exercise Four: determine whether the number of daffodils

Exercise five: the realization of a square

Output random numbers:

cycle:

Formatting Output (.format)

== is determined value, IS is the memory address is determined

 

 :( index, after the open before closing.)

Extract numbers:

 

Guess you like

Origin www.cnblogs.com/cqyyyyy/p/11272736.html