learn python hard way

Alibabacloud.com offers a wide variety of articles about learn python hard way, easily find your learn python hard way information here online.

Stupid way to learn Python (31)

!" - Else: - Print "Well , doing%s is probably better. Bear runs away."% Bear - + elifDoor = ="2": - Print "You stare to the endless Abyss at Cthulhu ' s retina." + Print "1. Blueberries." A Print "2. Yellow jacket clothespins." at Print "3. Understanding revolvers yelling melodies." - -Insanity = Raw_input (">") - - ifInsanity = ="1" orInsanity = ="2": - Print "Your body survives powered by a mind of Jello. Good job!" in Else: - Print "The

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 (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 (exercise1-15)

,%r tall,and%r heavy. "% (age,height,weight)#exercise12 prompting othersY=raw_input ("Name?") #这句话会用 "Name" prompts the user and assigns the result of the user input to the variable Y.#这就是我们提问用户并且得到答案的方式.Age=raw_input ("How old is You?")Height=raw_input ("How Tall is You?")Weight=raw_input ("How much does you weigh?")Print "So" is%r old,%r tall,and%r heavy. "% (age,height,weight)#exercise13 parameters, unzip, variableFrom sys import ARGVScript, first, second, third = argvPrint "The script is cal

Stupid way to learn python (29)

? What happens if you don't indent? Is it possible to put the other Boolean expressions in Exercise 27 in the "if statement"? Try it. What happens if I change the initial value of the variable people, Cats, and dogs ? Exercise Exercises1.The IF statement.if sentence1: sentence2The sentence one is the judgment part , of course, it can also be a Boolean expression of the previous lesson.The white space in front of the statement two is also part of the IF statement, and using i

Stupid way to learn Python exercise 42 plus points exercise

":Return ' death 'elif action = = "Slowly Place the bomb":Return ' Escape_pod 'ElseReturn ' The_bridge 'def escape_pod (self):Good_pod = Randint (1,5)Guess = Raw_input ("[Pod #]>>>")if int (guess)! = good_pod:Return ' death 'ElseExit (0)Class Engine (MAP):def __init__ (Self,start):Self.start = Startdef play (self):Next = Self.startWhile True:print "\ n-----------"GetAttr (Self,next)Next = Guest ()A_game = Engine ("Central_corridor")A_game.play () Remark: Beginner young novice, Welcome to the gre

Stupid way to learn Python (15)

this script with Raw_input, think of the way to get the file name better, and why.6. Run Pydoc file to scroll down until you see the read () command (function/method). See a lot of other orders, you can find a few to try. No need to look at the commands that contain __ (two underscores), these are just rubbish.7. Run Python again at the command line to open a file, this open and read method is also worth l

Stupid way to learn Python (32)

list6 forNumberinchThe_count:7 Print "This is count%d"% Number8 9 #Same as aboveTen forFruitinchFruits: One Print "A Fruit of type:%s"%Fruit A - #also we can go through mixed lists too - #Notice we have the use of %r since we don ' t know what's in it the forIinchChange : - Print "I got%r"%I - - #We can also build lists, first start with an empty one +elements = [] - + #Then use the range function to does 0 to 5 counts A forIinchRange (0, 6): at Print "Adding%d to the lis

Stupid way to learn Python (vi)

commas (comma). Just like you go to the store and say, "I want to buy milk, bread, eggs, eight treasures porridge," just as programmers say "(milk, eggs, bread, soup)."We will type a large number of strings, variables, and formatting characters, and print them out. We'll also practice using the shorthand variable name. Programmers like to use shorthand for annoying difficulty to save typing time, so let's learn this early so that you can read and wri

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

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 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 in the current directory, the $ mkdir Test001

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)

) 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 relation to escape sequences, think about why the la

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 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: 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

Total Pages: 15 1 .... 3 4 5 6 7 .... 15 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.