forked from Zipcoder/PyPart2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgreet.py
More file actions
31 lines (26 loc) · 968 Bytes
/
greet.py
File metadata and controls
31 lines (26 loc) · 968 Bytes
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
"""
Exercise 2
Create a script called greet.py.
- Define a function called greet that meets the following criteria:
- Takes an argument called name.
- Prints a greeting using the name parameter.
- Define another function called name_input that meets the following criteria:
- Takes no arguments.
- Prints a message to the screen requesting the user to provide a name.
- Returns a string with the value equals to that of the provided name.
- Using these two functions, prompt the user for a name and print it to the screen.
- Each function must have an appropriate docstring.
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())