The output is print ()
"" For character strings in (), no quotation marks for numbers The variable is variable name = "variable value" ex) name = "Shimajiro"
** Rules for naming ** Do not use numbers as initials Add _ for 2 or more words Attach with English words
** Benefits of using variables * Clarify what the contents of the data represent The same data can be used repeatedly You only need to change the value in one place
To add a number to an existing variable and assign it Variable name = variable name + numerical value Can be omitted with the operator = You can also concatenate characters with +
** Data type ** There are various types of data types ex) String type, numeric type Behaves differently with different data types Converting a data type is called ** type conversion ** Use ** "str" ** to convert a numeric type to a string type On the contrary, if you want to convert the string type to the numeric type, use ** "int" **.
** Conditional branch ** Divide the process according to whether a certain condition is met ** if statement ** Specify a conditional expression after if, and write the process to be executed when the condition is satisfied on the next line. if conditional expression: print ("processing")
In conditional expressions, the symbol ** "comparison operator" ** is often used to compare two values. == Equal! = Not equal if conditional expression **: ** ** In Python, the appearance (indentation) of the code directly affects the operation of the program *
** Boolean type ** "True and false type" includes "True" and "False" "True" when the conditional expression part using the comparison operator holds, "False" when it does not hold Symbols that compare the magnitude of values <,>, <=,> =
Processing when the condition is not met Use ** else ** When you want to define multiple cases where the condition is not met elif You can write as many elifs as you like, but it is judged from the top whether the conditions are met, and only the part that meets the conditions is processed first.
** Combine multiple conditional expressions ** and and or or not denial
list Manage multiple data together Create a list like [Element 1, Element 2] The value in the list is called ** element ** Can be assigned to a variable The numbers "0, 1, 2, ..." are assigned to the elements of the list in order from the front. This is called the index number Each element of the list can be obtained by using the list [index number].
Recommended Posts