Python First lesson (basic environment and software)

Source: Internet
Author: User

Python's own version check in the Mac10.12.6 version (I'm 10.12.6 myself is said to have more than 10.6 of its own is 2.7):

Open Terminal input: Python

You can see the output is 2.7 version, online to see some how to upgrade, personal experience is directly download the latest version of the installation, official website address: https://www.python.org/

My own use of this version, direct download, installation is click Next, completed after the terminal input: Python3:

This is the Python3.6 version installation is complete!

Re-install Pycharm, there is free version and pay version, I was directly on the Internet to find a registered link code directly cracked, of course, I am writing notes when I want to find out, I found that I have not found, anyway, is to download a installation is not difficult to install directly, Yin himself to buy or use the free version, The teacher said the free version of the can be used, I certainly do not know, because I happened to have found a crack!

What is that pycharm for? In short, you have to write the Python language to have a place to write it, then you can take it as the place!

Open after installation, select version 3.6

The path is probably the address of your saved file!

Go in after probably will appear a this kind of east, I do not know what is to turn off anyway, also have no influence

(Khan: English is too low to understand ...) )

Then create a new, that is, the code to write the page??

The following is a specific introduction to the Python first lesson I have learned something!!!

1. Output in print () this format;

2.if ... else ... statement, presumably to write a judgment, if ... How about it, otherwise, what's the other thing?

3. Cycle: For\while, this should be understood as I want to let something dry many times, give it a for or while, the specific difference is for his fixed format is that he has a package is the number, for I in Range (0,10,2): This inside I is a proxy is he can use other alternative such as ABC or something, people called variables bar as if, the general 0 in parentheses refers to from 0 to 10, and then 2 means that the result is a few out of one, the specific run about it will understand:

This is the first code I wrote:

Import Getpass  #这个是用来引用加密的包的, but the teacher said in the Pycharm this package is not used so, in other places can use it to represent the following # of the line of code can be put out;

user_name = "Nini"
Pass_word = "Qwe123"
Username = input ("username:") #它的意思好像是用户名就等于输入的用户名;
Password = input ("Password:") #这个的意思当然是密码等于输入的密码了;
#password = Getpass.getpass ("password") #引用函数加密密码, to first refer to the Getpass package, is the front of the import Getpass, where this came from, Python comes with;
Print (Username,password) #把这个连个变量输出到屏幕上来, or where the preceding input is entered, right? As smart as I am
If username ==user_name and password = = Pass_word: #if的条件是这个两个都相等, = = means absolute equals, and = is the equivalent of the variable, anyway, there is a definition of the variable when used =, really to equal time with = =;
Print ("Welcome user{name} longin ...". Format (name=username)) #上面条件完了记得加冒号: Then enter auto indent, well, look good! This line means that the first thing in the box is to output the parentheses.

else: #否则, you are dead, here;
Print ("Login failed") #输出括号里的东西, of course, the default parentheses are the characters, so the quotation marks will not come out;

Of course, # is a single comment, "..... "is a multiline comment single quotation mark can also be replaced with double quotes, in Python single double quotes basically no difference, of course, the teacher said, I certainly do not know!??

So I probably know that input is the type ... Dongdong, print is the output ... Dongdong, import Reference ... Stuff

name_01 = "Nini"
Count = 0
While Count <4:
Name = input ("Guess what my name is?") ")
If name = = name_01:
Print ("Wow, that's great, I'm the NI!") ")
Break
Elif name! = name_01:
Print ("Unfortunately, my name is not {NAME02}". Format (Name02=name))
Count +=1
If Count ==4:
Write = input ("Do you still want to guess?") ")
If write = = "Yes":
Count =0
Elif Write = = "not":
Break
Else
Print ("Your input does not match the rules, the game is over!") ")
Break

i_01 = "Nicole"
x_01 = ' 24 '
Count =0
While Count <6:
i = input ("Guess what my name is?") ")
Print (i)
x = input (' Please guess, myage is? ')
Print (x)
if i = = i_01 and x = = x_01:
Print ("Congratulations, oh, you guessed it!") ")
elif i = = i_01 and x! = x_01:
Print ("The name is right, the age is wrong Oh")
Elif I! = i_01 and X = = x_01:
Print ("The name is not right, the age guessed right")
Else
Print ("What kind of person, this guess is wrong?") Stupid dead. ")
Count +=1


i_01 = "Nicole"
x_01 = ' 24 '

i = input ("Guess what my name is?") ")
Print (i)
x = input (' Please guess, myage is? ')
Print (x)
if i = = i_01 and x = = x_01:
Print ("Congratulations, oh, you guessed it!") ")
elif i = = i_01 and x! = x_01:
Print ("The name is right, the age is wrong Oh")
Elif I! = i_01 and X = = x_01:
Print ("The name is not right, the age guessed right")
Else
Print ("What kind of person, this guess is wrong?") Stupid dead. ")




i = input ("What's your name?") ")
Print (i)



The exercises are all thrown up!!! That's it!





Python First lesson (basic environment and software)

Related Article

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.