How to set the value of a variable

To set the value of a variable, type the character(s) you want followed by "=" and then the desired value.

a = "hello"

number = 7

bananas = "Have a nice day!"

shopping_list = ["milk","bread","bananas"]

dic = {"AAPL":136}

a,b = 1,2

Python variable names can contain any alphabetic characters (A-Z and a-z), digits (0-9), and the underscore character "_".

Uppercase and lowercase letters are distinct. Therefore, Number and number are two different variables.

A digit cannot start a variable name. Therefore, street123 is a valid variable, 123street is not.

Built-in keywords and function names shouldn't be used as a variable name. For example, list or len.

How to create a function

Function is a block of reusable code.

Function blocks begin with the keyword def followed by the function name and parentheses ( ) and colon :.

Functions can be invoked by name and parentheses ( ).

def greetings():
greetings()

def math(a,b):
total = a + b
return total
math(5,7)

help(obj)

Built-in function is a great way to find all answers if you are new to Python. Example: help(str) and a help page will be printed on the console. You could see all available functions and methods for this particular object.