Python Tour (Basic 1-22)

Source: Internet
Author: User
Tags logical operators password book

formatted output: Format%s%d

The first type of notation:

# name=input (' name: ') # age=input (' Age: ') # job=input (' job: ') # info= "" # name:%s # age:%s # job:%s # "%(name,age,job)  # Print (info)

# name=input (' Please enter name: ') # age=input (' Please enter Age: ') # score=input (' Please enter your score: ') # % (Name,age,score) # print (MAG)

The second way:

 #   Name=input (' name: ')  #   Age=input (' Age: ')  #   Job=input (' job: ')  #   info="  #   Name:% s  #   Age:% (age)  s  #   Job:% s ' "% (     {"Age": Age, "job": Job, "name": Name}) #红色字体需要注意, because for the correct output location, the defined string must be written in%   #   print (info)  

%s is the placeholder for the string, in addition,%d, is the number placeholder, if the above age after the change of%d, it means you must only enter the number

#input接收的所有输入默认都是字符串格式!

Questions:

1. How do I convert str into a string?

int (Input ("age:")) Print (Type (age))

2. Now there's this line of code

msg = "I am%s, age%d, currently learning progress is 80%"% (' jinxin ', ') print (msg)

Error, because in the formatted output, you appear% default is the placeholder%, but I think the last 80% in the above statement is to represent 80% instead of placeholders, what to do?

msg = "I am%s, age%d, currently learning progress is 80%"% (' jinxin ', ') print (msg)

That's it, the first percent is the translation of the second% , telling the Python interpreter that this is just a simple%, not a placeholder.

logical operators:

#优先级
# () > Not > and > or

# Print (2 > 1 and 3 > 4) # Print (2 > 1 or 3 > 4) # print (not 2 > 1)
# a = 2 > 1 and 2 < 3 or 2 > 4 and 1 < 5 or 7 < 4
# Print (a)

#1, both before and after are the conditions of comparison

# Print (3 > 4 or 4 < 3 and 1==1) # F # Print (1 < 2 and 3 < 4 or 1>2) # T # Print (2 > 1 and 3 < 4 or 4 > 5 and 2 < 1) # T # Print (1 > 2 and 3 < 4 or 4 > 5 and 2 > 1 or 9 < 8) # F # Print (1 > 1 and 3 < 4 or 4 > 5 and 2 > 1 and 9 > 8 or 7 < 6) # F

#2, the numbers are all around.

# Print (1 or 2) # Print (2 or 3) # Print (0 or 2) # Print (0 or 3) # Print (1 and 2) # Print (0 and 3)

# x or y if X is True, the value is x; else: the value is Y.
# and contrary to or
‘‘‘
PS:STR---> int int (str) string must be a numeric component
int----> str str (int)

int---> BOOL non 0----> True
0-----> False
‘‘‘
# print (1 or 3 and 4 or 5)
# print (2 > 1 or 1 and 3 < 2)

History of the coding

War period:

Telegram, hair is high and low frequency, is actually 01010101 today 0000 0001
Late 0000 0101
Hi 0000 0111
Go 0000 1001

00000001 00000101 00000111 00001001

Computer:

storing files, or transferring files, is actually 010101010
The beginning of the computer creation, the USA, the binary,

Password Book:
Ascii
00000001
01000001 01000010 01000011 ABC

Because there are a lot of languages in the world, ASCII is not enough to store so many correspondence, creating a Super cipher Ben: Universal Unicode
8-bit = = 1 bytes.
Hello h a character, e a character, and he is not a character.
China: Medium is a character, the state is a character.
Unicode:
At the beginning of creation, 16-bit, 2-byte, representing a character.
English: A b C six bytes one English 2 bytes
Chinese Chinese four bytes one Chinese with 2 bytes
Change to 32-bit, 4-byte, representing one character.
A 01000001 01000010 01000011 00000001
b 01000001 01000010 01100011 00000001
Medium 01001001 01000010 01100011 00000001
Waste of resources.
To upgrade Unicode: Utf-8
Utf-8 uses a minimum of 8 digits to represent a character.
English: 8-bit, 1-byte representation.
European text: 16-bit, two-byte represents a character.
Chinese, Asian text: 24-bit, three-byte representation.
Utf-16 with a minimum of 16 digits.

Gbk
National standard, can only be used by the Chinese, a Chinese with 16 bits, two bytes of expression.

Unit conversions:
8 bit bit 8bit = = 1bytes
1024bytes = = 1kB
1024KB = = 1MB
1024MB = = 1GB
1024GB = = 1TB

In,not in:

Determines whether the child element is in the original string (dictionary, List, collection):

For example:

#print (' Like ' in ' I don't like watching TV ') #print (' A ' in ' Bcvd ') #print (' Y ' isn't in ' Ofkjdslaf ')

Python Tour (Basic 1-22)

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.