Recently viewed: stupid ways to learn python (learn python the hard way)Contents:
Translator Preface
The stupid method is more simple
Exercise 0: Preparing for work
Exercise 1: First program
Exercise 2: Annotations an
We have already learned about half of it, and the lower part is more interesting. We will learn logical judgment.
Before learning in the lower half, we should first perform a test. This test will be a bit difficult and we need to modify others' code. As a programmer, it is inevitable to modify other people's code, and these people often think that their code is perfect.
These people are stupid and do not care about others' feelings. Good programmers a
FalseWhat is 3 + 2? 5What is 5-7? -2Oh, that's why it's False.How about some more.Is it greater? TrueIs it greatet or equal? TrueIs it less or equal? FalseRoot @ he-desktop :~ /Mystuff #
Extra score exercise1. Add a comment to each line.# Percentage indicates the remainder.Print "Roosters", 100-25*3% 4
2. Like exercise (0), input python in Terminal, run python, and execute the above Code one by one.
3. Fin
Now it is time to review python keywords and symbols. The following lists some important python keywords and symbols.
Based on your memory, first write down the functions of these keywords, and then go online to find out their actual usage. Some of them may be difficult to find, but you should keep trying.
Write down the cards that you mistakenly remember, and write down the cards that you do not know. Then
You have spent a week learning the list in the previous exercise. Now we will spend another week reading some code online. This exercise is scary, just as I threw you into deep water for a few days, so that you can read some real project code. The goal is not to let you understand the code, but to teach you the following skills:Find the code you needRead the code and find the files.Try to understand the code you foundBased on your ability, you may not understand the code you found, but you can u
1.Windows under Installationhttps://www.python.org/downloads/download the appropriate version for installationNote: Add the Python installation path to the path path of the system environment variable to enter Python into the python environment under the command-line window 2.Linux installation tar.bz form TAR-ZJVF Compressed package c. Enter the u
0. Origins"Learn Python the hard" Exercise 46 requires four Python package pip, distribute, Nose, Virtualenv, (original book author Special reminder: do not just D Onwload these packages and install them by hand. Instead See how other people recommend you install these packages and use them for your particular system.)
: append (mystuff, 'Hello ').In most cases, you don't have to know what is going on, but it helps when you encounter the following error:Www.2cto.com :~ # PythonPython 2.6.5 (r265: 79063, Apr 16 2010, 13:09:56)[GCC 4.4.3] on linux2Type "help", "copyright", "credits" or "license" for more information.>>> Class Thing (object ):... Def test (hi ):... Print "hi"...>>> A = Thing ()>>> A. test ("hello ")Traceback (most recent call last ):File "TypeError: test () takes exactly 1 argument (2 given)>>>
W
honey.The fat bear is in front if another door.How are you going to move the bear?> Taunt bearThe bear has moved from the door. you can go through it now.> Taunt bearI got no idea what that means.> Open doorThis room is full of fold. How much do you take?> 4Man, learn to type a number. Good job!Root @ he-desktop :~ /Mystuff # python ex35.pyYou are in a dark room.There is a door to your right and left.Which
Now we enter more variables and print them. We usually use "" to refer to strings.
Strings are quite convenient. In practice, we will learn how to create strings containing variables. There is a special way to insert a variable into a string, which is equivalent to telling Python: "Hey, this is a formatted string. Put the variable here ."
Enter the following prog
We have learned printing and mathematical computation. Next we will learn variables. in the program, variables are a name, which makes it easier for us to remember.
If you are overwhelmed by the following exercises, remember the methods we taught before and find different points. Pay attention to the details:1. Write comments for each line of code.2. Read the code in turn.3. Read your code.
[Python]1. cars
In the following example, we will pass a variable to the script. Do you know why you enter python ex13.py to execute the ex13.py file? The command "ex13.py" is actually a "parameter". Let's write a script that can accept parameters.[Python]1. from sys import argv2.3.4. script, first, second, third = argv5.6.7. print "The script is called:", script8. print "Your first variable is:", first9. print "Your secon
Next, we will learn the if statement and enter the following code to ensure proper running.[Python]People = 20Cats = 30Dogs = 15If people Print "Too success cats! The world is doomed! "If people> cats:Print "Not found cats! The world is saved! "If people Print "The world is drooled on! "If people> dogs:Print "The world is dry! "Dogs + = 5If people> = dogs:Print "People are greater than or equal to dogs ."If
Next we will do some interesting things. if you follow the progress, you will find that you can use the if statement and Boolean expression to do a lot of things.
In any case, the program will do some repetitive tasks. Next we will print a list variable with a for loop. During this exercise, you must understand their meanings and functions.
Before using the for loop, we need to save the value of the loop. The best way is to use a list. The list is the
Is the title long? I am introducing you to functions. Every programmer has different opinions, but now I will only teach you the simplest usage.
Functions do three things:They name the code, just like assigning a variable name to strings and numbers.They receive parameters, just like argv in the script.Use articles 1 and 2 to implement your own mini scripts or small methods.If you use def to create a function, four functions are created and the relationships between them are displayed.[
for each of them, or you can choose to buy the physical book (or donate) If you want to support the author, which I'm sure they wowould greatly appreciate.Learn python the hard way
Despite the name, learn python the hard
) returns an int of type 4). Input () handles what you enter as Python code, which can be a security issue. Unless there is a special need for input (), it is generally recommended to use raw_input () to interact with the user. Note: Python3 input () receives the STR type by default. x = Int (raw_input ()) Converts the user input string int () to an integer raw_input () in parentheses to enclose the hint message y = raw_input ("Name?") 7.
Php Chinese network (www.php.cn) provides the most comprehensive basic tutorial on programming technology, introducing HTML, CSS, Javascript, Python, Java, Ruby, C, PHP, basic knowledge of MySQL and other programming languages. At the same time, this site also provides a large number of online instances, through which you can better learn programming... Reply: The best time to do one thing is 10 years ago,
0. Reply content: the best time to do one thing is 10 years ago, followed by the present. Buy this movie and see how dave cutler started programming at the age of 2x. After 10 years, he dominated the Silicon Valley kernel programmers. Non-computer majors. It's not too late for a senior to start programming because he started programming. Maintaining Long-Term Interest is the most important thing. In addition to playing football (once), this is the only sport I have maintained a long-term interes
it is very helpful.
3. since IT is an IT company, there is little basic knowledge, such as a variety of classic algorithms, OS, and databases.
4. Python is just a language. What truly reflects the level is computing thinking.
In addition, you can search for the Python Web framework on Zhihu and learn a lot about it. Hard
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.