-
Notifications
You must be signed in to change notification settings - Fork 0
/
11_Functions-Ex.py
20 lines (17 loc) · 1.01 KB
/
11_Functions-Ex.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
def greeting(name, age = 28, color = 'red'):
#Greets user with 'name' from 'input box' and 'age', if available, default age is used
print('Hello ' + name.capitalize() + ', you will be ' + str(age+1) +' next birthday!')
print(f'Hello {name.capitalize()}, you will be {age + 1} next birthday!')
print(f'We hear you like the color {color.lower()}! {color.lower()} is a string with color')
name = input('Enter your name: ')
age = input('Enter your age: ')
color = input('Enter favourite color: ')
greeting(name, int(age), color)
# 1. Add new print statement - on a new line
# which says 'We hear you like the color xxx! xxx is a string with color
# 2. extend the function with another input parameter 'color', that defaults to 'red'
# 3. Capture the color via an input box as variable:color
# 4. Change the 'You are xx!' text to say 'you will be xx+1 years old next birthday
# adding 1 to the age
# 5. Capitalize first letter of the 'name', and rest are small caps
# 6. Favorite color should be in lowercase