Getting day1 python

Today, roughly python understand the power of this language, and the need to master the era of artificial intelligence programming language, the team deepened my interest in learning such courses. 
The next study in the teacher's teaching some basic syntax, the following are relevant finishing:

Print
( ' ! The Hello world ' ) '' ' (! The Hello world') Print ' ' '' # name = 'Tank' # # Print (name) # ID, type, value X = 10 Y = 10 '' ' Python small counting chamber (Python optimization mechanism): within the variable value to produce a specified range in the memory in advance to open up a memory space, and respectively the variables within the specified range of storage inside. '' ' # Print (ID (X)) # Print (ID (Y)) # name =' Tank ' # Determination value are equal # Print (X == Y) # determines whether the same id # Print (X Y IS) # Constant (constant is variable in python we have stipulated that uppercase variables are called constant) SCHOOL = ' Anhui Polytechnic University ' # users interact with a program # name = the iNPUT ( 'the iNPUT your name:') # pwd = the iNPUT ( 'Please enter your password:') # # Print (name, pwd) # Print (of the type (name) , type (pwd)) '' ' python2: the raw_input () to python3: INPUT () ' '' # numeric type # integer int # number 100 # = int (100) # number2 = int (100) # Print (Number) # Print (number2) # float a float # SAL 15.0 # = a float (15.0) # SAL2 = a float (15.0) # Print (SAL) # Print (SAL2) # string type # name = 'Tank ' # NAME2 = "Tank" # Content =' '' # 1r1r1r # 21r12r1 # r12r # 12r1r21 # r12r1r2 # 12r1r # '' ' # # Print (name, NAME2, Content) # Python strings can be summed, multiplied #Print ( 'Tank' *. 5) # Print ( 'Tank' + 'Jam') # Print ( 'Tank', 'Jam') # List Type # [] brackets separated by commas, can be stored a plurality of different types of value. # List1 = [ 'Zhang Man-Man', 'tank', 'Tu Yi Lei',. 11, 1.0, [ 'Jason', 200 is]] # Print (List1 [0]) # Print (List1 [. 5] [0]) # dictionary type # in the {} are separated by commas, can be stored a plurality of values, each value key: value stored in the form # memory # dict1 = { 'name': "Tank", "Age":} # 18 is name = { "Tank", "Age"} = 18 is # take # Print (dict1 [ "name" Print (== 10. 11) False # # Note: All data types Boolean own, 0, None, are empty False # IF 0: # Print ( '111') # # IF None: # Print ( '111' ) # # IF []: # Print ( '111') # # the else: # Print ( '222') # format output # may be a string type as a replacement when the output # % S placeholder,% d digital type may alternatively # number = iNPUT ( 'enter:') # str1 = '' ' # Dear user, your credit balance membered% s. # '' ' # list1 = [1, 2, 3, 4, 5] # for line in list1: # print(line) # for line in range(1, 10): # print(line) # dict1 = {'name': "tank", "age": 18} # for key in dict1: # print(key) # print(dict1[key])

# '' ' 
# Str1 =' XXX My name IS, IS 18 is My Age ' 
# # eliminate spaces around Strip 
# Print (str1) 
# Print (str1.strip ()) 
# # segmentation Split 
# List2 = str1.split ( '') 
# Print (List2) 
# str2 = 'My name IS XXX, My Age IS 18 is' 
# for Line in str2: 
#      Print (Line, End = "") 
# STR6 = 'My name in Tank' 
# Print ( str6.lower ()) 
# Print (str6.upper ()) # Lower upper uppercase to lowercase 
# Print (str6.startswith ( 'My')) is determined #startswith front endswith Analyzing rear 
# Print (str6.startswith ( 'My'))
#Print (str6.endswith ( 'Tank')) 
# #fomat three kinds of play 
# STR7 = 'My name in {}, {} My Age IS' 
# STR7 = str7.format ( 'Tank', 18 is) 
# Print (STR7 ) 
# 
# STR7 = 'My name in {}. 1, 2} {My Age IS' 
# STR7 = str7.format ( 'Tank', 18,111) 
# Print (STR7) 
# 
# STR7 = 'My name in {name}, Age Age {iS} My ' 
# STR7 = str7.format (name =' Tank ', Age = 18 is) 
# Print (STR7) 
# ' '' 
# # of the Join list according to some data identifying a character to be spliced splicing string type 
# name = 'Tank' 
# Age = '20 ' 
# Print (':'.join([name,age]))
##replace 
# Str8 = 'new new Old' 
# Str8 = str8.replace ( 'Old', 'new new') 
# Print (Str8) 
# #isdigit numeric string is determined whether 
# ID = INPUT ( 'Enter') 
# Print (ID) 
# Print (ID.isdigit ()) 
List1 = [ ' Tank ' , 18 is, ' womale ' , 3.0,9 ]
 Print (List1 [. 4 ])
 Print (List1 [-2 ]) 


# '' ' 
# str1 = 'XXX My name IS, IS 18 is My Age' 
# # eliminate spaces around Strip 
# Print (str1) 
# Print (str1.strip())
## Segmentation Split 
# List2 = str1.split ( '') 
# Print (List2) 
# str2 = 'XXX My name IS, IS 18 is My Age' 
# for Line in str2: 
#      Print (Line, End = "") 
# = STR6 'My name in Tank' 
# Print (str6.lower ()) 
# Print (str6.upper ()) # Lower upper uppercase to lowercase 
# Print (str6.startswith ( 'My')) is determined #startswith behind the front endswith Analyzing 
# Print (str6.startswith ( 'My')) 
# Print (str6.endswith ( 'Tank')) 
# #fomat three kinds of play 
# STR7 = 'My name in {}, {} My Age IS' 
# STR7 STR7 = .format ( 'tank',18)
# print(str7)
# 
# STR7 = 'My name in {}. 1, 2} {My Age IS' 
# STR7 = str7.format ( 'Tank', 18,111) 
# Print (STR7) 
# 
# STR7 = 'My name in {name}, My iS} {Age Age ' 
# STR7 = str7.format (name =' Tank ', Age = 18 is) 
# Print (STR7) 
# ' '' 
# # of the Join list according to some data identifying a string of splicing to the splice type 
# name = 'Tank' 
# Age = '20 ' 
# Print (': '. the Join ([name, Age])) 
# #replace 
# Str8 =' new new Old ' 
# Str8 = str8.replace (' Old ', 'new') 
# Print (Str8) 
# whether the string number is determined #isdigit 
#ID = input ( 'Enter') 
# Print (ID) 
# Print (ID.isdigit ()) 
List1 = [ ' Tank ' , 18 is, ' womale ' , 3.0,9 ]
 Print (List1 [. 4 ])
 Print (List1 [-2 ])
 Print (List1 [. 1:. 5: 2 ]) 

Print (len (List1))
 # append the append () 
list1.append ( ' sjkd ' )
 Print (List1)
 # remove pop () default last -1 
Print (list1.pop ())
 Print (list1.pop (0))
 Print (List1) 
List1.
# Cycle
 
 

Homework part:

name = " alex"
name = name.strip()
print(name)
name1 = name.startswith('al')
print(name1)
name2 = name.endswith('x')
print(name2)
name3 = name.replace('l', 'p')
print(name3)
name4 = name.split('l')
print(name4)
print(name.upper())
print(name.lower())
print(name[2])
print(name[1:4])
print(name[-2:-1])
print(name.index('e'))
print(name[0:len(name)-1])

Summary: As one of the most popular programming languages ​​python has the following advantages

  • 1. Easy to learn: Python has relatively few keywords, simple structure, grammar and a well-defined learning curve easier.

  • 2. Easy to read: Python code defines more clearly.

  • 3. Easy to maintain: Python's success lies in its source code is fairly easy to maintain.

  • 4. A wide range of standard library: One of the biggest advantages of Python's library is rich, cross-platform, in UNIX, Windows and Macintosh compatible well.

  • 5 may be embedded: can be embedded into the Python C / C ++ programs.

 

Guess you like

Origin www.cnblogs.com/yt2223/p/11006707.html