print hello world
and execute it. The console will print out hello world
. Completing this step will defeat 25% of people.item = "banana"
, here we come into contact with Python's first data type, string, which can be enclosed in double quotes or single quotes.item_price = 5
.is_happy = True
indicates whether something is true or false, which will have important uses in the future. Completing the relevant operations can defeat 40% of people.+
before and after the connection must be consistent, so there are many ways to use built-in functions to convert data types. Complete this step and you can defeat 50% of the people.is_happy = False
, for conditional judgment. When a certain condition is met, the corresponding code is executed. Completing the relevant operations can defeat 55% of people.for
loop, such as for i in range(10000):
i
is the current number of loops (starting from zero), you can use it as needed.while True:
means it is always true, but the loop interruption logic can be set internally. For example, if the user enters '0' and uses the 'break' keyword to break out of the loop, completing this step will defeat 80% of people.print
, int
, range
, input
, etc. are all Python's own methods.pass
keyword inside the method to avoid program errors, but you must come back later to implement the internal logic of the method, otherwise it may be difficult to locate. bug. Completing this step will defeat 85% of people.try-except
. Under try
is the normal execution content, and under except
is the program exception execution content. In order to make the program more interactive, you can give users reminders and prompts in except
. Completing this step can defeat 90% of people.
Comments
There are currently no comments