Python Basic Learning Day 1

Source: Internet
Author: User

Beginner python, record your journey ~

Understand the basic concept of Python, now use more is python2.7

Learned the If statement and two classic loop statements

#about the application of the IF statementName = Raw_input ('Input Name') Age= Input ('Input Age')#You can also use inputSalary = Raw_input ('Salary')#use an If statement to always have only one result, which ends when the condition is metifAge > 60: Msg='You is too old'elifAge > 30: Msg=' you aren't young'Else: Msg='You is still young'Print" "information of%s:name:%s age:%d salary:%s________________________%s" "% (name, name, age, salary, MSG)#must one by one correspond
#about for Loop (guess age)Real_age = 18 forIinchRange (10): Age= Input ('Age :')    ifAge >Real_age:Print 'think smaller'    elifAge <Real_age:Print 'think bigger'    Else:        Print ' You is right'         Break    Print 'You still has%s shots'% (9-i)
#about the While loop (number of selected prints)ImportSysnum=0count=0 whileCount <=1000:    ifCount = =Num:Print 'There is the number', Count whileNum <=Count:num= Input ('which number does want? Inuput 0 to exist')            ifnum = =0:sys.exit ()ifNum <=Count:Print 'it 's over'            Else:        Print 'Loop:', Count Count+ = 1Else:    Print 'Loop:', Count

Python Basic Learning Day 1

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.