First week of Python learning, first week of python
print("Hello word!")
Therefore, python is a very concise language. Unlike c, c ++, and so on, you have to call a bunch of libraries to write a simple program. In addition, python 3 supports Chinese compiling.
Python is a dynamic, strong language
name="fromzore"print(name)
You do not need to define the type of the variable. The system automatically defines the variable according to the input.
Name = "fromzore" age = input ("age"); pt2 = "% s your age is % s" % (name, age) print (pt2)
In input, the str type is input by default. To use % d, force conversion is required.
Name = "fromzore" age = int (input ("age") pt2 = "% s your age is % d" % (name, age) print (pt2)
No error is reported.
The loop is divided into a while loop and a for loop. The difference between the loop and c is that python can be followed by else statements.
age=18sum=0while sum<3: count= int(input("age")) sum+=1 if sum==count: print("you are right") break elif age<count: print("It is biger than age") elif age>count: print("It is smaller than age")else: print("Multiple input errors")
The result is as follows:
For Loop
for i in range(3): count= int(input("age")) sum+=1 if sum==count: print("you are right") break elif age<count: print("It is biger than age") elif age>count: print("It is smaller than age")else: print("Multiple input errors")
Changing while to for results is the same.
Ps: there is an error in the first blog posting or where it is not well written. Please give me more advice.