Question: Instructions Most assignments going forward will have starter code. The assignment instructions are a combination of text instructions before the starter code and comments written

Instructions

Most assignments going forward will have starter code. The assignment instructions are a combination of text instructions before the starter code and comments written inside the starter code. Read all of the comments in the code provided to you.

Moving forward we will largely be using unit tests that check the behavior of specific functions.

The goal of this assignment is...

...to practice writing functions and to practice working with strings. Do not import any modules to complete your work.

Use the Homework CheckerLinks to an external site. to check your work.

Tasks:

Implement the following functions in the given code:

repeat() get_int_from_user() get_float_from_user() get_equation_string_for_modulus()

I recommend you call your own functions a few times to test them out. Just print() out the result and see if it makes sense.

Remember: Parameters contain values that are passed in by the caller. You will need to make use of the parameters that each function has. Do not change the parameters. Do not change the names of the parameters and do not change the values of the parameters. Just make use of the values given to you.

Also: if you don't have any test code that calls your functions then when you run your program it will load, execute, appear to do nothing, and finish. Unless you call your functions after defining them, there is nothing more to do. The console will show a new prompt, but that's it. So, to check your work, you will need to write code outside of these functions.

Starter code:

# We're going to practice writing functions that manipulate strings. def concatenate(textA, textB): ''' Concatenates strings textA and textB together. ''' return textA + textB def repeat(text, n): ''' Repeats the string text, n times. Expecting n to be an integer. ''' pass def get_int_from_user(question): ''' Uses the given question to ask the user for a number and returns an int. ''' pass def get_float_from_user(question): ''' Uses the given question to ask the user for a number and returns a float. ''' pass # In the function get_equation_string_for_addition() below you can see I have provided three return statements. # Only the first return statement is actually executed. The other two return statements are just examples # of how you can write an equivalent line of code; the second and third return statements will be ignored # because the interpreter will never reach them. def get_equation_string_for_addition(x, y): ''' Returns a string that represents an addition equation. ''' return '{} + {} = {}'.format(x, y, x + y) # return a string that demonstrates an addition equation return '{0} + {1} = {2}'.format(x, y, x + y) # equivalent to previous line return f'{x} + {y} = {x + y}' # equivalent to previous two lines def get_equation_string_for_modulus(x, y): ''' Returns a string that represents a modulus equation. ''' # Use get_equation_string_for_addition() as an example of the text you are meant to produce. # The goal here is to perform a modulus operation and return a string that represents the operation performed. pass 

Previous

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!