The next step is to learn the variables: replace complex strings with simple variables
the first letter of the variable cannot be a number or a special symbol ~! @#¥ and so on.
Development of character Sets:
ASCII 255a1an account1bytes------>1980yearsGB2312Support7thousand Men--------->1995years,GBK10, Support2Wmany men------>2000years,GB18030Support27000Many men,-----Unicode,Man accounted for2bytes, but English is not good to store------->utf8,1an English account1bytes,1a man accounted for3of bytes
Example One: ( compiled and run in Pycharm, followed by the same code)
Method One:
Name=input ("Name:")
Age=input ("Age:")
Job=input ("Job:")
Salary=input ("Salary:")
Info= ""
------Info of%---------
name:%
age:%
job:%
salary:%
"% (name,name,age,job,salary)
Print (info)
Method Two:
Name=input ("Name:")
Age=input ("Age:")
Job=input ("Job:")
Salary=input ("Salary:")
Info= ""
------info of {_name}--------
Name:{_name}
Age:{_age}
Job:{_job}
Salary:{_salary}
". Format (_name=name,_name=name,_age=age,_job=job,_salary=salary)
Print (info)
The following is the proofreading of the account password:
_username= ' Xiangxiao ' #(the default value is in single quotes)
_password= ' abc123 '
Username=input ("Username:")
Password=input ("passwoed:")
If _username==username and _password==password:
Print ("Welcome {name} come here ...". Format (name=username))
else:
Print ("Failed password or username")
Note : When compiling in Pycharm, pay attention to the first line indent,indentationerror to indicate indentation error
Circular precautions:
Break: ends the current loop
Continue: end this cycle and proceed directly to the next cycle
Example two: Guess the age, to achieve the actual age, ask to guess three age, more than three times, then exit the cycle;
oldboy_age_of=56
Count=0
While count<3:
Guess_age=int (Input ("Guess_age:"))
If Guess_age==oldboy_of_age:
Print ("You is Right")
Elif Guess_age<oldboy_of_age:
Print ("Please guess bigger")
else:
Print ("Please guess smaller")
If count==3:
Guess_confirm=input ("Does want to guess it?")
If guess_confirm! = ' n '
Count=0
Else
Print ("You have tried too much ...")
Python base language and IF/WHILE statement structure