Python full stack __format formatted output, while else, logical operator, encoding initial knowledge

Source: Internet
Author: User
Tags password book

1, formatted output. %d%s
Formatted output:% placeholder, d for Replace Integer, and s to replace string.
Name = input (' Please enter first Name: ') Age = input (' Please enter ages: ') Sex = input (' Please enter Gender: ') msg = ' My name is ' + ' + ' my age is ' + ' my gender is ' + sexprint ( Msg

msg = "------------info of Alex Li-----------Name  : Alex liage   : 22job   : Teacherhobbie:girl------------- End-----------------' Print (msg)

D represents the replacement integer number, and S indicates the string to replace.

Name = input ("Enter Name:") age = Int (input ("Enter Age:")) job = input ("Please enter work:") hobby = input ("Please enter hobby:") msg = "'------------info of %s-----------Name  :%sage   :%djob   :%shobbie:%s-------------end-----------------'% (name, name, age, Jo b, hobby) print (msg)

DIC = {    ' name ': ' Old boy ',    ' age ': +, '    job ': ' Boss ',    ' hobby ': ' money ',}msg = ' '------------info of% (name) s -----------Name  :% (name) SAge   :% (age) Djob   :% (Job) Shobbie:% (Hobby) s-------------end----------------- "% Dicprint (msg)

In the formatted output, you need to represent a pure percent percent, to be expressed as a double percent percent.

msg = ' My name is%s, this year%d, learning progress 2%%. '% (' cool sister ', ') print (msg)

2. While else

While else, when the loop of while is interrupted by a break, it does not go to the ELSE program.

Count = 0while Count <= 5:    count + = 1    print (' Loop ', count)    if Count = = 4:        breakelse:    print (' Loop normal execution ') print ("-----out of the while loop------")

3. Operators

1, before and after the logical character is the comparison operation

Priority concepts:

() > Not > and > or

The same priority is calculated from left to right.

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

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)

2, before and after the logical characters are digital

Or

X or Y, if x Ture,return x, Else Return y.

X!=0,x is Ture.

Print (3 or 5)

Print (2 or 5)

Print (0 or 5)

Print ( -4 or 5)

Print (1 or 3 or 0)

Print (1 or 3 or 4 or 0)

and

The rules of and are the exact opposite of or.

Print (3 and 5)

Print (1 > 2 and 3 or 4)

Conversion of numbers and bool values

int---> BOOL  non 0 True, 0 False
BOOL---> int True 1, False 0
Print (bool (100))
Print (bool (0))

4, the first knowledge of coding

Spy war film: Drip drop drops high and low level, 0101010

The storage of computer files, and the transfer of files. 010101010

Primary Password Book:

ASCII code letters, numbers, special symbols.

0000 0001 8 Bit = = One byte, one byte represents one character.

Character: the smallest unit that makes up the content.

ABC a b C

China China

Universal code: Unicode

Create an initial 16-bit, two-byte representation of one character.

a:01100001 01100001

Medium: 01100011 01100001

After the upgrade 32 bits, four bytes represent one character.

a:01100001 01100001 01100001 01100001

Medium: 01100011 01100001 01100011 01100001

Waste of resources. (HDD, traffic, etc.)

For Unicode Upgrade: Utf-8

Utf-8: At least one character is represented by a 8-digit number.

A:01100001 (Letters are represented by 1 bytes.) )

European script: 01100001 01100001 (Europe is represented by 2 bytes.) )

Asian text-Medium: 01100001 01100001 01100001 (Europe is represented in 3 bytes.) )

Utf-16: A minimum of 16 bits is used to represent one character.

GBK: National standard.

a:01100001

Medium: 01100001 01100001

8 bits compose a byte

1024bytes 1kb

1024KB 1MB

1024MB 1GB

1024GB 1TB

Python full stack __format formatted output, while else, logical operator, encoding initial knowledge

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.