forked from Zipcoder/PyPart3
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmultilingual_greeter.py
More file actions
52 lines (39 loc) · 1.45 KB
/
multilingual_greeter.py
File metadata and controls
52 lines (39 loc) · 1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
"""
Exercise 3
Copy the greet.py program from part 2 and name it multilingual_greeter.py
Extend the program so that it meets the following requirements.
- Add a function called language_input that gives the user an option to choose 1 of at least 3 languages.
- Ask the user for his name in the chosen language.
- Greet the user in the chosen language.
Answer below:
"""
def greet(name):
"""
function greet takes name as argument and prints a greeting using this name argument
"""
print('Hello ' + name)
def name_input():
"""
function name_input returns string of a name provided as input by the user
"""
name1 = str(input('Please provide a name: '))
return (name1)
greet(name_input())
#Program extension to meet the multilingual requirements
def language_input():
lang = str(input("Choose one of the four languages here: English, Spanish, Hindi, Telugu \n"))
if lang == "English":
name2=str(input('Please provide your name in the chosen language \n'))
print("Hello " + name2)
elif lang == "Spanish":
name2 = str(input('Como te llamas \n'))
print("Hola " + name2)
elif lang == "Hindi":
name2 = str(input('Aap ka naam kya hain \n'))
print("Namaskar "+ name2)
elif lang == "Telugu":
name2 = str(input('Mee perenti \n'))
print("Namaskaram "+ name2)
else:
print("You need to select your language from only the four option provided")
language_input()