Python the second day

the perpetual day here make me confused about the time. I thought it was only 13 or 14 until saw the clock which showed it was 17 already.

Keep going python study

Screenshot from 2015-09-06 18:38:56

Screenshot from 2015-09-06 18:41:46

You write the name of the desired new type in the same way as a function call, for example

x = float("3.4")
print(x-1)

The input() function takes no arguments and always gives back a str.

By calling input() multiple times, you can access multiple lines of input. The first call to input() gets the first line, the second gets the second line, et cetera.

Screenshot from 2015-09-06 19:09:18

if没括号,后面有冒号,下一句要空格

  • Then, the body consisting of one or more indented lines. The number of spaces (the amount of indentation) doesn’t matter, but being inconsistent will cause an error since Python uses the amount of indentation to determine where you mean the body to start or stop.

Boolean expressions

print(2>1)
b = False
print(b)
print(type(b), type(2>1), type(True))
True
False
<class 'bool'> <class 'bool'> <class 'bool'>

Note that in Python, when you use the bool values True and False directly in a program, they must be capitalized or you will get an error.

 

Advertisements
Python the second day

Python really get into the world of programming, first day

this is the first day when I really start working to become a programmer, using the lab computer with linux.

Since I don’t know why I can’t type Chinese with correct formation, english will be it.  So let’s begin.

Today I start to learn python, and here is the note:

# thanks to uwaterloo’s computer science circle

definition of variable doesn’t need the type of it.

Screenshot from 2015-09-05 19:36:56

Screenshot from 2015-09-05 19:45:11

EOL is short for End Of Line  ///  EOF is short for End OFile

Screenshot from 2015-09-05 19:49:44

Screenshot from 2015-09-05 21:05:04

Python really get into the world of programming, first day