The first day of Python learning

Source: Internet
Author: User

Today I've learned more about Python's outlook and basics (development tools, variables, formatted output, loops)

1.python variables: Used to store data, dynamic types that don't need to be defined, but require strong conversions
Name= "Peter"
age=11
Age=int (Input ("age"))
2. Formatted output
Name = input ("Name:")
age = Int (input ("Age:"))
#第一种方法
info = "info for%s,name:%s,age:%d"% (name,name,age)
Print (info)
#第二种方法
Info2 = "info for {name},name:{name},age:{age}". Format (Name=name,age=age)
Print (Info2)
3. Cycle (While,for,brek,continue)

Age Game:

#年龄判断
age_of_jim=39
Count=0
While count<3:
Age=int (Input ("Age:"))
If Age==age_of_jim:
Print ("Yes,guess got It")
Break
Elif age<39:
Print ("Guess is smaller")
Else
Print ("Guess is bigger")
Count=count+1
If count==3:
Continue_confirm=input ("Continue_confirm:")
If continue_confirm! = ' n ':
Count=0
If count==3:
Print ("You guess Fail")

#for Cycle
For I in Range (0,10):
Print ("--", i)
For j in Range (10):
Print (j)
If j>5
Break

    

The first day of Python learning

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.