learn python 3 hard way review

Discover learn python 3 hard way review, include the articles, news, trends, analysis and practical advice about learn python 3 hard way review on alibabacloud.com

Stupid way to learn Python (exercise 0)

First, learn to use terminal to create a directoryMkdir--make Directory CreationUsage: $ mkdir Example:1, $ mkdir Test001Create a "Test001" directory under the current directory2, $mkdir test001/test002Create the directory "test001/test002" under the current directory, and generate the appropriate directory if the directory "test001/test002" does not exist.3. If a file (or folder) named Test001 is present i

Lpthw stupid way to learn Python 40 Chapter Class

Today read the 40th chapter of LPTHW after the enlightened, the original has been dull, do not understand the definition and use of the class, there is not quite understand the definition of self.class MyStuff (object): def __init__ "and nowa thousand years between"def Apple: print "I AM classy apples! "  Say the class and the Mini module is similar, then for the class, there must be an import-like concept. The concept name is "instance (instance)". This is just a acting knowledgeable, it

Stupid way to learn python (11)

) behind each line of print, right? In this case, print will not output new line breaks and end this line to the next line.You should see the result:Bonus points Exercise1. Surf the web to find out what features Python Raw_input implements.2. Can you find any other usage of it? Test the example you searched for online.3. Write a paragraph in a similar format and change the question to your own.4. In relatio

Stupid way to learn Python: functions and files

fromSysImportArgvscript,input_file=argvdefPrint_all (f):PrintF.read ()defRewind (f): F.seek (0)defPrint_a_line (line_count,f):Printline_count,f.readline () current_file=Open (input_file)Print"First let ' s print the whole file:\n"Print_all (current_file)Print"Now let's rewind, kind of like a tape."Rewind (Current_file)Print"Let ' s print three lines:"Current_line=1print_a_line (current_line,current_file) current_line=current_line+1print_a_line (current_line,current_file) current_line=current_lin

Python's Way "first": Python Basics (3)

Import Getpass[[email protected] ~]# cat Test_getpass.pyimport getpassusername = input ("username:") password =Getpass.getpass ("Password:") print (Username,password) [[email protected] ~]# Python3 Test_getpass.pyusername:jam Password:jam Hello[[email protected] ~]# C:\users\jam>python2python 2.7.11 (v2.7.11:6d1b6a68f775, Dec 5, 20:40:30) [MSC v.1500-bit (AMD64)] on Win32typ E "Help", "copyright", "credits" or "license" for more information.>>> import getpass>>> username = Inpu T ("usernam

Stupid way to learn Python (26)

exercises 24 and 25 into a file, deleted some of the characters at random, and then added some bugs in. Most of the error is that Python will tell you when it executes, and there are some arithmetic errors you want to find out for yourself. All that's left is formatting and spelling mistakes.All of these errors are easily made by programmers, even if experienced programmers are no exception.Your task is to modify this file correctly and use all your

Lpthw stupid way to learn Python Chapter 16

Some extensions are made according to the content of chapter 16.For example, if a file exists, it is appended to the file and created if it does not exist.It also draws on a method similar to the cat Now there is a small pit, how to use Python to read a file of the number of rows, the original Os.system ("Wc-l filename") is OK, but how to operate under Windows? Fill it back.#!/usr/bin/env python#-*-coding:u

Stupid way to learn python exercise 18 naming, variables, code, and functions

Next we start to learn about "functions." The function can do the following 3 things. 1, they name the code snippet, just like "variable" to string and to name 2, they can accept the parameters, just like your script accepts argv. 3, using # and #, they let you create "mini script" or "small command" First, put the code: (slightly modified with the code in the te

A simple way to learn Python 1

How to open a file in cmd : First open the cmd interface with Win+r , after the address known to you to open the file, such as (f:\ Workspace), you press F:and then you enter workspace with the CD workspace File , and then put in the file you want to open (the name + file type), and then you can open the file. in the in Python, the function of entering characters is:input(which can be any character), and the characters in parentheses are printed .The

Stupid way to learn Python (20)

Print_a_line runs, you pass a variable called current_line . Each time the function is called, the current_line is printed out to track how it becomes line_count in the print_a_line . Find out where each function is used in the script. Check the def line to verify that the parameter is not used correctly. Go online and study what the seek function in file does. Try running pydoc file to see if you can learn more. Consider the function of the s

Stupid way to learn Python (1-10)

the same, for example, to deal with an int type Object%r will be more "on the side of the string."String (srring) and textW = "This is the left side of ..." E = "a string with a right side." Print W + ethis is the left side of...a string with a right Side.print "." * 10 .....Printdays= "Montuewedthufrisatsun" months= "Jan\nfeb \nmar\napr\nmay\njun\njul\naug "print" herearethedays: ",days print "herearethemonths:",monthsprint "" "There ' s Somethinggoingonhere.withthethreedouble-quotes.we ' Llbe

Stupid way to learn Python learning notes

Created on: 2016-02-29Update: 02-29Python version: 2.7 %r is good for debugging because it shows the raw data of the variable, while the other symbols are used to show the output to the user; Print will not output line breaks If you add one after each line of print (comma). argv command-line arguments are strings, so it is necessary to convert int () to a number when the number is involved, raw_input () is also a string. Common ways to read and write files: close,read,readline,tru

"Stupid way to learn Python" 18th Lesson notes __python

the 18th lesson of the stupid way to learn Python This class will create a function that is similar to the definition function in the C language. The author adds an English comment that explains the function at the beginning of each function. For ease of understanding, I will directly explain some of the code involved in the knowledge point after the original co

Learn python from ' Head first Python ' [3] (2): Pickle

1.the use of ' with open ... '2.the use of pickle (dump and load)For STEP1:The ' with open ... ' is the short format of ' try...except...finally 'For STEP2:You can store a list with pickle.dump () and get the content again with Pickle.load ()1>>>ImportPickle2>>> with open ('Test.pickle','WB') as data:3Pickle.dump (['a','2','et'],data)4 5 6>>> with open ('Test.pickle','RB') as ReadFile:7The_list =pickle.load (readFile)8 9 Ten>>>the_list One['a','2','et'] A>>>When use this method, you shou

The way to learn Python

to query (enter Q exit):" ") Company="'#pre-defined units whileCompany! ='Q': Department=input ()ifDepartment = ='Q': Break elif notDepartmentinchDic_of_ncepu:Print('The system is not queried, please re-enter') Continue Else: ifLen (dic_of_ncepu[department]) = = 1: Print(Dic_of_ncepu[department])Else: Print('Please enter the subordinate units of the department you are inquiring about: (press B to return, press Q to exit)') whileTrue

Lpthw stupid way to learn Python chapter 20

This section describes the integrated operation of functions and files.were carried out separately. 1, read out all the contents of the file, 2, reset the file to the beginning of the file. 3, print a line.I made a small improvement in this section, set up a global variable, record which line should be entered at the moment, and if so, I'll add one to the number.The code section is as follows:#!/usr/bin/env python

Stupid way to learn Python's modules, classes, objects

are like importedIf the class is like a module, then there should also be an import-like concept. In a class, this concept is called instantiation, and when a class is instantiated, it gets the object of a class.Create a class;Class MyStuff (object):def __init__ (self):SELF.A = ' How is it? 'def apple (self):Print ("I am classy apple")b = MyStuff () #类的实例化B.apple () #调用类的方法Print b.a# properties of the printing classAnalyzing the instantiation of a class this sentence actually

Stupid way to learn python (i)

Environment: notepad++,python2.7.13Compile: Write the. py file first, and then run the script with the Python command in the terminal (the runtime terminal directory to be located in the running. py file directory)Exercise One:In the Python2 version, the double quotation mark "" and the single quotation mark "can be used for output without parentheses, and the statement ends without a semicolon;When you want to output quotes in a sentence, you can use

Stupid way to learn Python (11-20)

print" We have it girls with%d. The number of "% nv_countprint" IT staff: >>> Nan_nad_nv (60,20) Results The number of IT staff is: we have 60 of it boys. We have 20 of it girls.19. Functions and variablesdef cheese_and_crackers (Cheese_count, boxes_of_crackers): print "You had%d cheeses!"% cheese_count print "you h Ave%d boxes of crackers! "% boxes_of_crackerscheese_and_crackers (20, 30) results you have a total of cheeses! You have a boxes of Crackers!amount_of_cheese = Amount_of_crackers = C

NO 3, Life is short, I learn python python Ganso tuple magic

1 #meta-ancestor elements cannot be modified, cannot be added and deleted2 #Ganso is also orderly.3Tu = (12,'SF', 27,67,34,7,9,4,3,5,7)4 Print(TU)5 #Ganso can be converted to str,list with each other6 #Ganso can be sliced to iterate over an object7 #the first-level element of Ganso cannot be modified, but it is only a level element8T = ('a','b', ['A','B'])9T[2][0] ='X'TenT[2][1] ='Y' One Print(t) NO 3, Life is short, I

Total Pages: 5 1 2 3 4 5 Go to: Go

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.