-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Expand file tree
/
Copy pathwrite-a-simple-function.py
More file actions
33 lines (28 loc) · 1.07 KB
/
write-a-simple-function.py
File metadata and controls
33 lines (28 loc) · 1.07 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
'''
Write a simple function
100xp
In the last video, Hugo described the basics of how to define a function.
You will now write your own function!
Define a function, shout(), which simply prints out a string with three
exclamation marks '!!!' at the end. The code for the square() function that we
wrote earlier is found below. You can use it as a pattern to define shout().
def square():
new_value = 4 ** 2
return new_value
Note that the function body is indented 4 spaces already for you. Function bodies
need to be indented by a consistent number of spaces and the choice of 4 is common.
Instructions
-Complete the function header by adding the appropriate function name, shout.
-In the function body, concatenate the string, 'congratulations' with another string,
'!!!'. Assign the result to shout_word.
-Print the value of shout_word.
-Call the shout function.
'''
def shout():
"""Print a string with three exclamation marks"""
# Concatenate the strings: shout_word
shout_word = 'congratulations' + '!!!'
# Print shout_word
print(shout_word)
# Call shout
shout()