Python variable definition and print output instance

Source: Internet
Author: User

1. Example of basic parameter definition
Print ("Hello World")

Name = "Paoche Ge"

name2 = Name

Duohang = "'
Print ("My name is", name)

Name = "Mr Li"

Print (Name2, "and", name)
‘‘‘

Print (Duohang) #打印duohang Multiple lines!

Username = input ("Username:")
Password = input ("Password:")
#打印多个参数

2, print out:
Name = input ("Name:")
age = Int (input ("Age:"))
Print (Type (age), type (str))
Job = input ("Job:")
Salary = input ("Salary:")

#不建议这种拼接方式, inefficient
info = ""
---------------Info of----------
Name: "+ name +"
Age: "+ Age +"
Job: ' + Job + '
Souru: ' + Souru + '
‘‘‘


Info1 = "'
---------------Info of%s----------
ame:%s
age:%d
job:%s
salary:%s
"% (name,name,age,job,salary)


Info2 = "' #建议这种方式
---------------info of {_name}----------
Aame:{_name}
Age:{_age}
Job:{_job}
Salary:{_salary}
". Format (_name=name,
_age=age,
_job=job,
_salary=salary)

Info3 = "'
---------------info of {0}----------
AAME:{0}
Age:{1}
JOB:{2}
SALARY:{3}
". Format (name,age,job,salary)
#print (INFO1)
Print (INFO3)


Python variable definition and print output instance

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.