Python first day

Source: Internet
Author: User

To set the program template in Pycharm:

#! usr/bin/env python   #声明环境变量, Windows does not need #-*-coding:utf-8-*-          # Author Burnywen

Variable:

" Burnywen " Print ("burnywen")
" Burnywen " name2   = name   "banana"   #name2直接指向burnywen, do not change with name to print (name, name2)  output: Burnywen burnywenbanana  

Binary:

Decimal:                 8   4    2    1    binary 1    0      0    0   0   1   0

Ascii:

Decimal corresponding characters
48-57 0-9
65-90 A-Z
97-122 A-Z

Formatting:

Name = input ("Name:") Age=int(Input ("Age :")) #转换为integerjob= Input ("Job:") Salary=int(Input ("Salary:") Info="""----------Info of%s------------Name:%Sage:%Djob:%ssalary:%D"""%s (name,name,age,job,salary)Print (info) Info2="""#特定场景下只能用这种----------info of {_name}------------Name:{_name}age:{_age}job:{_job}salary:{_salary}""". Format (_name = name,_age =Age , _job=Job, _salary=salary) Print (Info2) Info3="""----------Info of {0}------------name:{0}age:{1}job:{2}salary:{3}""". Format (name,age,job,salary)print (INFO3)

Guess_age Mini-game:

#! usr/bin/Env python#-*-coding:utf-8-*-# Author Burnywenage_of_burnywen= atCount=0 whileCount <3: Age=int(Input ("Guess Age:"))    ifAge = =Age_of_burnywen:print (" You is right")         BreakElif Age>Age_of_burnywen:print ("think smaller ...")    Else: Print ("think bigger ...") Count+=1    ifCount = =3: Retry= Input ("want to try? y/n")        ifRetry! ="N": Count=0        ContinueElse: Print ("End ...")

Python first day

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.