Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

beginner python Assignment 5 (void returning Functions with parameters) Question 1: (15 points) Write a function that takes no parameters as input and inside the

beginner python
image text in transcribed
image text in transcribed
Assignment 5 (void returning Functions with parameters) Question 1: (15 points) Write a function that takes no parameters as input and inside the function should ask the user to input (enter) a String asking for your favorite sport: and then prints "My favorite Sport is sp." where sp is the given input string. So in your program you ask "What is your favorite sport?" So if an user inputs Basketball inside the function the output should look like: My favorite sport is Basketball. Question 2 ( 30 points) Write a function in Python that takes one parameter for the number of rows (n) to display. The input number of rows should be asked in the main and passed into the function as an argument. Using nested loops it should then display that many rows of numbers starting from 1 to n on the first line, 1 to n1 in the second line and so on and just 1 on the last line. The program should be able to run for any value of n. For example if n is entered as 5 , there should be 5 lines printed out and there should be 12345 in the first, 1234 in the second, 123 in the third, 12 in the fourth and 1 in in the last line. A sample run would look like this where n=5 : Enter number of rows: 5 ( Asked in main ) and the function prints the following numbers inside the function: ( Please note one space between each number.) 12345 1234 123 12 Question 3:( 45 points ) Write a function to print the lyrics of our own version of the song "Old MacDonald". One Stanza of the song is given below. You have to add two more stanzas with a different character and super power (instead of the spider man and the spider-sense). Your python program should print the lyrics for three different characters and their respective powers using one function called three times, similar to the example verse below: Write a function that takes two parameters (string1, string2) the character name and the super power it has to write one stanza. Then this function should be called from main three times to write the whole lyrics. Here you call the function thrice with three different characters and their respective powers and do not ask the user to input. Output will be the lyries of the song with three stanzas. Please note the " "*" for the power which should be in the output. Old MacMarvel had a universe, E-I-E-I-O And on his universe he had a SpiderMan, E-1-E-I-O With a "spider-sense" here and a "spider-sense" there Here a "spider-sense" there a "spider-sense" Everywhere a "spider-sense" Old MacMarvel had a universe, E-I-E-1-O Please write the three functions called from main in a program called Assgn5_Firstname.py. Call the functions firstname_fav_sport, firstname_nested_loop and firstname_nursery_rhyme and call from the main. (10 points) First function should take no parameters, second function should take one argument ( number of rows) and third function should take two parameters (character, power). Submit the .py in a zip file as usual. Substitute your firstname in place of firstname and substitute your lastname in place of lastname. Once again please remember to add comments and the header for the file. So when you run the main, output should be like: My favorite Sport is Basketball. ( Where Basketball is the favorite sport entered as input within the function.) A blank line Number of rows with numbers as specified in the requirements. (Where number of rows are input by the user in the main.) A blank line The whole nursery rhyme printed with three stanzas each stanza with a different character and the respective power they possess. (Where the three characters and power are hardcoded by the programmer(you) and not asked as input) A blank line

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases A Beginners Guide

Authors: Andy Oppel

1st Edition

007160846X, 978-0071608466

More Books

Students also viewed these Databases questions