Assignment 18 — function introduction
Due October 24
Module olio.py
- Complete the implementation of four functions. Program use_olio.py is available to help you test your module
olio
functions.
Function voting_age()
- Does not take any parameters. Returns an integer indicating how old you need to be to vote. For example, the following code segment initializes both x and y to the integer
18
.
x = olio.voting_age()
y = olio.voting_age()
Function has_blanks( s )
- Has one parameter
s
. Returns whethers
contains at least one blank character; i.e., returnsTrue
ifs
contains a blank, and returnsFalse
otherwise. For example, the following code segment initializesb1
andb2
toTrue
andFalse
respectively.
x = 'CS 1112'
y = 'the_aarvark_said_arf_arf'
b1 = olio.has_blanks( x )
b2 = olio.has_blanks( y )
Function great_seal()
- Does not have any parameters and does not return a value. The function prints text from the Great Seal of the United States, i.e., E Pluribus Unum.
- The code segment
olio.great_seal( )
print()
olio.great_seal( )
print()
produces as output
E Pluribus Unum
E Pluribus Unum
Function a_ing( n )
- Has one parameter
n
. The function does not perform a return, instead it printsn
lines of output. The first line prints a single'a'
, the second line prints'aa'
, the third line prints'aaa'
, and so on. The string operator*
should prove useful. For example usage, the code segment
olio.a_ing( 5 )
print()
olio.a_ing( 1 )
print()
olio.a_ing( 3 )
produces as output
a
aa
aaa
aaaa
aaaaa
a
a
aa
aaa
© 2019 Jim Cohoon | Resources from previous semesters are available. |