The road to survival Python W1

Source: Internet
Author: User

The first day of the beginner's program, always starting with Hello World, Python is no exception;

1. Try the first Python program print output:

1 Print ("Hello World! ") ")

Operation Result:

2. Assign variables and branch outputs:

    • Use print () as the information output;
    • Use XXX = YYY, give the value of yyy to xxx;
    • Use the input () statement to get the user output information, then assign the variable (to the left of the = number), use the INT () statement to restrict the input type, int to shape, and the default to string (string)
    • Use the ' ' ' Comment text and format it, and finally call the print () output.
1 #Registration of Student information2 Print("Please enter the following student information:")3s_id = Int (input ("School Number:"))4S_name = input ("Name:")5s_age = Int (input ("Age:"))6S_class = input ("class:")7 8 #Enter the above registration information and export the Student information card9Stu_info =" "Ten ------------Student Information card: {s_name}----------- One  A Study number: {s_id} - name: {s_name} - Age: {s_age} the class: {S_class} -  - --------------------------------------- - " ". Format (s_id=s_id,s_name=s_name,s_age=s_age,s_class=S_class) +  - Print(Stu_info) + Print(S_name,"data entry is complete! ")

Operation Result:

The road to survival Python W1

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.