Python Full stack development-week1

Source: Internet
Author: User

The first week mainly introduced the history of Python, and some current applications.

Variable

Python's writing process will use a lot of data, that for the convenience of operation, it is necessary to use a simple name to represent the data, easy to reference in the next program, the variable is to represent a data (value) name.

1. Variable names can include letters, numbers, underscores, but numbers do not start

2, the System key words can not do variable name use

  

' Hello world! '
Print (VAR)

After execution

Hello world!

Character encoding

  Character encoding from ASCII, to GB2312, GBK, GBK18030, to the present Unicode, because the English of Unicode occupies too much memory, so that after the UTF-8 optimization, a Chinese character takes up 3 bytes and an English character occupies 1 bytes.

If Else

  

1_username ='Doulen'2_password ='home1234' #声明用户名和密码的变量3 4Username = input ('Username:')5Password = input ('Password:')    6 7 ifUsername = = _username andPassword = =_password:8     Print('Welcome {name}, login ...'. Format (name=username)) #只要输入的用户名密码和预先存的一致 then output this passage .9 Else:Ten     Print('username or password is wrong') #否则 Output This passage

While loop

1True_age = 242Count =03  whileCount < 3:4g_age = Int (input ('Age :'))5chances = 2-Count6 7     ifG_age = =True_age:8         Print('You got it!')9          BreakTen     elifG_age >True_age: One         Print('oops! think smaller, you had%s chances left'%(chances)) A     Else: -         Print('oops! think bigger, you had%s chances left'%(chances)) -Count +=1 the Else: -     Print('You have guessed too many times')

Let the user choose to continue or terminate at their own discretion

1True_age = 242Count =03  whileCount < 3:4g_age = Int (input ('Age :'))5chances = 2-Count6 7     ifG_age = =True_age:8         Print('You got it!')9          BreakTen     elifG_age >True_age: One         Print('oops! think smaller, you had%s chances left'%(chances)) A     Else: -         Print('oops! think bigger, you had%s chances left'%(chances)) -Count +=1 the     ifCount = = 3: -Countine_comfirm = input ('Do you want countine?y/n:') -         ifCountine_comfirm! ='N': -Count = 0

Python Full stack development-week1

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.