Jul 8, 2024
python --version
in Command Prompt.python --version
should now show the version.python
in Command Prompt).1 + 2
, print("Hello World")
.exit()
.Ctrl+Shift+P
→ Python: Select Interpreter
→ Choose installed version.variable_name = value
red_bucket = "Kevin"
red_bucket = 10 # Overwrites 'Kevin'
type(variable)
returns the type (e.g., str
, int
).del variable_name
var = input("Message")
+
, -
, *
, /
.**
//
%
"Hello"
or 'Hello'
).#
.'''
or """
.if condition:
# Code block
elif another_condition:
# Code block
else:
# Code block
if age < 5:
print("Preschool")
elif age == 5:
print("Kindergarten")
else:
print("Other class")
def function_name(parameters):
# Code block
def print_hello():
print("Hello")
print_hello()
def add(a, b):
return a + b
result = add(3, 4) # Returns 7
while condition:
# Code block
Example:
x = 0
while x < 5:
print(x)
x += 1
for variable in iterable:
# Code block
Example:
for x in range(5, 10):
print(x)
import library_name
import math
print(math.pi) # Prints value of Pi