python four basic operations and data types

# Print (. 1, 2,. 3,. 4,. 5) 
# Print ( "Python")
# Print ( "Python")
# Print ( "Python")
# Print ( "Python")
# Print ( "Python")
# Print ( "Python")


# value calculation: + - * / // (modulo) **
# Print (2 **. 3)



# Print (1.2-1.1)
# Import decimal
# Print (decimal.Decimal ( "1.2") -decimal.Decimal ( "1.1")) # import method of introducing decimal. 1

# import decimal
# A = decimal.Decimal ( "1.2")
# = B decimal.Decimal ( "1.1") # import introducing decimal variable assignment method 2 ab
Print # (A - B)



# value of a first part type
# a = 123 # integer
# b = 1.23 # float
# c = 2j # complex (hereinafter must be followed by a plurality of J became complex)
# D # Boolean = True (only two True False) very important

# print (5 <6) # when compared True true
# print (5> = 6) # when compared False false



# Import math # rounding method in module
## rounded up and rounded down
#
# A = Math.ceil (+ 2.2. 5). 8 #
# Math.floor B = (2.2 +. 5). 7 #
#
# Print (A)
# Print (B)


# cast

# a = 5 # integer
# b = 1.2 # floating point
# c = True # Boolean
# d = 2j # plural
# type See What is the data type
# print (type (a )) # int: integer
# print (type (b)) # float floating point
# print (type (c)) # bool Boolean
# print (type (d)) # complex plural
# e = float (a) # floating point
Print # (E) # 5.0
# Print (type (E)) float #
# print (int (b)) # integer (1 is 1.2, 1.9 is 1)
# Print (int (C)) # 1
# Print (int (False)) # 0
# Print (BOOL (0)) #False
# Print (BOOL (-9.9)) # True
# Print (bool (9)) # True ( boolean other than 0 is false (False), the other either positive or negative or decimal is true (True) is non-zero real



# second part of the sequence type
# 1 character string str =
# Print ( "Love")
# Print ( "1 + 3")
# inner tube brackets "" is a string, the string no matter where the content is what will print out the contents of the string when the digital operation can not be entered What is, or what to print out.

# 2 list list =
# list represents a whole, the list of which can put any type of data, for each type of data which need to be separated by a comma,
# each data type is independent individual, and inside each data type do not have any relationship, they just exist among this list only. At the same time
# a = "ah ah ah ah"
# li = [ "abc", 123, 1.2, True, 1J, a , [ "jelly", 2, "M"]]
# if two different types of data need to be separated by a comma
# Print (Li)
# Print (type (Li)) List #

#. 3 if the multi-tuple = tuple a case where the outside case of variable comma-separated list box columns with no automatic Transforming into a tuple
# x = ( "abc", 123, 1.2, True, 1j, [ " jelly", 2, "M"




# Z = [ "jelly", 2, "M"]
# S = [ "jelly Mom" 30, "F"]
# Print (S [0])
# Print (Z [0])
# Print (S [ 2])

# 5 takes a value between a slice of a range called the closed left and right sections are not taken before the end of open access
# [start position: end position + 1'd]

# S = [ "jelly mother", 30 "F ", 123]
# Print (S [0:. 3]) # can not write back the colon may be taken after the last number a
# print (s [-2]) # start value is -1 from the right to the first such push


# print out the case if only one tuple element is a string, if only one type of holder element want tuples must be a comma after the element,
# H = ( "ha")
# Print (H)
# Print (type (H))

# brackets element must specify a change values from zero can be changed to use the list of supported element tuple string immutable elements
# li = [ "jelly mother", 30 , "female"] may change list elements #
# # lo = ( "jelly mother", 30, "F") # tuple immutable elements
# li [0] = "babe"
# # LO [. 1] = ' 20 '
# Print (you)
# # print (it)
#
# = d 'qweasdztgb'
# print (d [3])
# D [2] = 'v ' strings are immutable elements
# type sequence are possible values indexed by slice





# job
# 01 define a list, the list there are four types of values, a variety of ways to take The third value

# A = [10, 8.8, True,. 4J]
# Print (A [-2])
# Print (A [2])
# Print (A [2:. 3])
# Print (A [-2 : 1])


# 02 has a form (201,905,018), required to give in this format, month, day

# B = "201905018"
# Print (B [0:. 4])
# Print (B [. 5:. 6] )
# Print (B [. 7:])

# = 201 905 018 C
# Print (C // 100000)
# Print (C //% 1000 2019)
# Print (C% 2.01905 million)













Guess you like

Origin www.cnblogs.com/gd000-/p/11565995.html