Life is short, I will be happy to learn Python! 3. The basic data types

First, note the string

1. quotation marks ( '' or ''), a pair of single or double quotes, three pairs of single or three pairs of double quotation marks, the contents of the intermediate string.

= NAME1 " mop " 

NAME2 = ' Lara ' 

NAME3 = "" " captain " "" 

NAME4 = '' ' Viva! ' ''

 

2. adding:

name = name1 + name2 + name3 + name4
print(name)

 

3. multiplication:

longlive = name * 10
print(longlive)

 

Second, digital

Numbers can add, subtract, multiply, divide, power, business, the remainder run

a1 = 27

a2 = 4

a = a1 + a2 

a = a1 - a2

a = a1 * a2

a = a1 / a2

a = 2 2 ** 2 represents a power of 2

a = a1% a2 a2 is divided by the number 27 on behalf of I 3 is obtained

a = a1 // a2 a2 representative of a quotient obtained by dividing 27 6

For example, seeking a = 13 is odd or even, as follows:

a = 13
res = a % 2
if res == 0:
    print("偶数")
else:
    print("奇数")

Guess you like

Origin www.cnblogs.com/ntgale/p/12070475.html