thisdict = {
"brand": "Ford",
"model": "Mustang",
"year": 2026
}
print(thisdict["year"])
i = 1
while i < 6:
print(i)
i += 1
i = 1
while i < 6:
print(i)
if i == 3:
break
i += 1
i = 1
while i < 6:
print(i)
if i == 3:
break
i += 1
i = 1
while i < 6:
print(i)
i += 1
else:
print("i is no longer less than 6")
fruits = ["apple", "banana", "cherry"]
for x in fruits:
print(x)
fruits = ["apple", "banana", "cherry"]
for x in fruits:
if x == "banana":
break
print(x)
for x in range(6):
if x == 3: break
print(x)
else:
print("Finally finished!")
adj = ["red", "big", "tasty"]
fruits = ["apple", "banana", "cherry"]
for x in adj:
for y in fruits:
print(x, y)
for x in [0, 1, 2]:
pass
def fahrenheit_to_celsius(fahrenheit):
return (fahrenheit - 32) * 5 / 9
print(fahrenheit_to_celsius(77))
print(fahrenheit_to_celsius(95))
print(fahrenheit_to_celsius(50))
def my_function(fname):
print(fname + " Refsnes")
my_function("Emil")
my_function("Tobias")
my_function("Linus")
def my_function(animal, name):
print("I have a", animal)
print("My", animal + "'s name is", name)
my_function("cat", "Serpentina")
def my_function(person):
print("Name:", person["name"])
print("Age:", person["age"])
my_person = {"name": "Emil", "age": 25}
my_function(my_person)
def my_function(x, y):
return x + y
result = my_function(5, 3)
print(result)
def my_function(a, b, /, *, c, d):
return a + b + c + d
result = my_function(5, 10, c = 15, d = 20)
print(result)
def my_function(*args):
print("Type:", type(args))
print("First argument:", args[0])
print("Second argument:", args[1])
print("All arguments:", args)
my_function("Emil", "Tobias", "Linus")
def my_function(*numbers):
if len(numbers) == 0:
return None
max_num = numbers[0]
for num in numbers:
if num > max_num:
max_num = num
return max_num
print(my_function(3, 7, 12, 9, 1))
def my_function(**kid):
print("His last name is " + kid["lname"])
my_function(fname = "Tobias", lname = "Refsnes")
def my_function(**myvar):
print("Type:", type(myvar))
print("Name:", myvar["name"])
print("Age:", myvar["age"])
print("All data:", myvar)
my_function(name = "Tobias", age = 30, city = "Bergen")
def my_function(username, **details):
print("Username:", username)
print("Additional details:")
for key, value in details.items():
print(" ", key + ":", value)
my_function("emil123", age = 25, city = "Oslo", hobby = "coding")
du=pow(4,3)
print(du)
print(bool(0))
To embed this project on your website, copy the following code and paste it into your website's HTML: