Functions with Input
def greet():
for i in range(3):
print("Hello, World!")
greet()
def developerGreetings(name):
print(f"Hello {name}!")
print("Are you ready for Google I\\O?")
developerGreetings("Oliver")
Postionals VS Keyword Outputs
# Postionals
def developer(name, lang):
print(f"Hi, {name}")
print(f"{lang} is wonderful language for SW Engineering!")
developer("Oliver", "Python")
#Keyword
def phone(name, phone1):
print(f"Hi, {name}!")
print(f"{phone1} is a great phone in the market!")
phone(name="Oliver", phone1="Nothing phone(2)")
Paint Area Calculator
h = int(input("What is the height: "))
w = int(input("What is the width: "))
c = 5
def paintedArea(h, w):
area = h*w
cans = int(area/c)
print(f"You will be needing {cans} cans.")
paintedArea(h, w)
Prime Number Checker
number = int(input("Enter the number: "))
def primeCheck(n):
isPrime = True
for i in range(2, n):
if n % i == 0:
isPrime = False
if isPrime:
print("It's a prime number")
else:
print("It is not a prime number")
primeCheck(number)