In [1]:
days = 7
hours = days * 24
minutes = hours * 60
print(minutes)
10080
Functions¶
Functions in a programming language like python can take in values and return a value. It is similar to a function in math
In [7]:
def emphasize(statement):
refrase = statement.upper()
refrase = refrase + "!"
return refrase
print(emphasize("Hello"))
HELLO!
Loops¶
Loops, or iteration, allow us to have a computer to run code multiple times. It is a part of flow of control, generally tied to a condition. In the case of the example below, as long as the expression evaluates to true the loop keeps running. Once it is no longer true, the program will exit the loop.In [2]:
def greet(times):
i = 0
while i < times:
print("Hello!")
i += 1
greet(5)
Hello! Hello! Hello! Hello! Hello!
In [ ]: