Pyhton variables and data types

A variable

Python variable naming conventions:

1, the variable name can only contain numbers, letters, underscores, and can not use numbers beginning.

  eg: message_1 is right but 1_message is wrong

2, the variable name can not contain spaces.

3, when the variable name, you can not use keywords.

Pyhton of 33 keywords

33 key details, see: https://cloud.tencent.com/developer/article/1409147

Second, the data type

Integer: 1,2,3,4,5 ....

Float: 1.2333,3.1415926 .., 2.000 .......

Integer and floating point may be subjected to conventional four arithmetic operations and exponentiation (**) ** 2 = 9 3

Empty Type: None (None type is not equal to 0)

字符串:'Python is my favorite lanuage.',"This is a string.",'This is also a string.'.....

#Exercise 

message = "Hello Python World!" #message string for storing a string variable, the variable is equivalent to a container
print (message)

message = 'Hello flash Python World! ' # update message variable value
print (message)

 

# Circumference and area of ​​a circle

print ( "Please enter the circle's radius:")
R & lt int = (INPUT ())
PI = 3.14
C = 2 * PI * R & lt
S = R & lt * PI * R & lt
print ( "perimeter of a circle:", c)
print ( "area of a circle is:", s)

Case # string conversion
name = "Lovelace ada"
Print (name.title ()) #title () method are shown in uppercase first letter of each word in a way
print (name.upper ()) #upper ( ) method string to all uppercase
print (name.lower ()) #lower ( ) method of the string to all lowercase

#字符串的合并( 用"+"将字符串合并 )
first_name = "ada"
last_name = "lovelace"
full_name = first_name + " " + last_name
print(full_name)
print("Hello,"+full_name.title()+"!")
message = "Hello,"+full_name.title()+"!"
print(message)

#制表符(\t)和换行符(\n)
print("Python")
print("\tPython")
print("Languages:\nPython\tC语言\nJavaScript\tC#\n")

 

 

 

Guess you like

Origin www.cnblogs.com/sinlearn/p/10932310.html