python--formatted output, operator

Source: Internet
Author: User
Tags logical operators password book

#例题
a=1
b=2
c=3
print (a,b,c)
Print (111)
if 3>2:
Print (333)
if True:
print (555)
Else:
print (444)
Print (888)

#字符串的拼接:
#打印我叫大哥, 26 years old this year, my sex is male
# name=input (' Please enter your name: ')
# age=input (' Please enter your Age: ')
# sex=input (' Please enter your gender: ')
# msg= ' I call ' +name+ ' this year ' +age+ ' years ' + ' my sex is ' +sex
# Print (msg)

#格式化输出% placeholder S d
#例打印名片
#第一种:
# name=input (' Please enter your name: ')
# Age=int (Input (' Please enter your Age: '))
# job=input (' Please enter your Occupation: ')
# hobby=input (' Please enter your hobby: ')
# msg = " "
#------------Info of%s-----------
# Name:%s
# Age:%d
# Job:%s
# Hobby:%s
#-------------End-----------------
# '% (name, name, age, job, hobby)
# Print (msg)
# #第二种:
# dic ={' name ': ' Xiao Wang ', ' Age ': ' Job ': ' Farmer ', ' hobby ': ' Play '}
# msg = " "
#------------Info of% (name) s-----------
# Name:% (name) s
# Age:% (age) D
# Job:% (Job) s
# Hobby:% (hobby) s
#-------------End-----------------
# "% dic
# Print (msg)
#格式化输出, in formatted output, the mere representation of% needs to be expressed in percent.
msg= ' My name is%s, this year%s, learning Progress 2% '% (' Cool girl ', ' ")
Print (msg)

#while Else when the while loop is interrupted by a break, it does not go to the ELSE program.
count=0
While count<=5:
count+=1
print ("Loop", Count)
if Count==4:break
Else:
print ("Loop normal execution")
print ("----out of a while loop----")

# operator

Print (2 > 1 and 3 < 4 or 8 <10 and 4 > 5)

#第一种情况 Logical operators are comparison operations before and after
#优先概念: () >not>and>or, the same priority is calculated from left to right.
Print (2 > 1 and 3 < 4 or 4 > 5 and 2 < 1)
Print (1 > 2 and 3 < 4 or 4 > 5 and 2 > 1 or 9 < 8)
Print (1 > 1 and 3 < 4 or 4 > 5 and 2 > 1 and 9 > 8 or 7 < 6)

#第二种情况 logical operators are numbers before and after
" "
x or y if x True, return x, else y
" "
Print (3 or 5)
Print (2 or 5)
Print (0 or 5)
Print ( -4 or 5)
Print (3 and 5)
Print (0 and 3)
Print (1 or 3 or 4 or 0)
Print (1 or 3 or 0)
Print (1>2 and 3 or 4)
" "
#数字与bool值转化
#int--->bool not 0 True, 0 False
#bool0--->int True 1, False 0
" "
print (BOOL)
Print (bool (0))


#编码初识
First Knowledge password book: Asscii
Universal code: Unicode
Initial creation: 16-bit two bytes represents one character.
Upgrade: 32-bit four bytes represents one character.
Utf-8: A minimum of 8 digits to represent a character.
utf-16: A minimum of 16 digits to represent a character
GBK: National Standard
ASSCII-->UNICODE-->UTF-8-->GBK
1024bytes =1kb
1024kb =1MB
1024MB =1GB
1024GB 1TB

python--formatted output, operator

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.