print() #Display the corresponding as a character string
type() #Returns the type in parentheses
int() #Returns the applicable integer value
max() #Returns the maximum value
min() #Returns the minimum value
abs() #Returns the absolute value
sum() #Returns the total value
len() #Count the number of elements
divmod(a,b) # a/b[quotient,remainder]
def kansuu(a,b,c,....): #The function name is arbitrary. a,b,It feels like defining an argument as a variable with c.
.... #If processing is performed by the return value, describe the processing content.
return Return value#In some cases it may not be. When there is no return value, such as Print.
#Variables used in a function can only be used within it (scope). ⇄ Global variables
#Rewriting a global variable inside a function does not affect the global variable because it is inside the function.
global a
#However, if you do the above, you can rewrite the global variable a from within the function. Just deprecated.
from Stored file name import Function name
#After import*It is also possible to bring all the functions with. However, if possible, select only the functions to be used.
#Because I don't know what kind of function is in it, so it may be confusing when using it.
if __name__ == '__main__':
....
#It's like a magic trick that doesn't work when importing what is done on the storage file side.
#Strictly__name__Is the executable file name."__main__"An image that looks like an open file.
def main()
....
if __name__ == '__main__':
main()
#By doing this, it is also possible to write a long sentence below if and not to enable it as a function.
tupul = (aaa,bbb,ccc) #A list that cannot be changed later. The first variable name can be anything.
a = "Element 1"
b = "Element 2"
a , b = "Element 1" , "Element 2" #Unback substitution part ①
a , b = ( "Element 1" , "Element 2" ) #Unback substitution part 2
a , b = [ "Element 1" , "Element 2" ] #Unback substitution part ③
#Tuples can also be entered as dictionary keys. On the other hand, the list is not possible.
val = 1 #Initial definition
while val < 10: #Continue execution as long as this condition is met
print(val)
val += 2
print("val->",val)
break #While when there is a condition that you want to stop iterative processing~~ :You can end it with break.
continue #When you want to skip the iterative process only that time While~~ :Used with continue.
#While True if you want to continue executing indefinitely unless specified by break:It seems that you should call.
Recommended Posts