Waiting for answer This question has not been answered yet. You can hire a professional tutor to get the answer.


Roman Numeral Lab Python Conditionals and Functions Part 1: 1) Write a Python program, that prompts the user to enter a number within the range of 1...

roman_num = 'Error!'main()Part 2: Defining FunctionsModify the program to use functions. 1) Use Save As to change the name of your program so you won't overwrite the Part 1program.2) Define a main function by adding this before the first line of your program         def main()    Now indent your entire program, selecting everything below def main(), and choosing"Indent Region" from the format menu.Now, add the call to main() at the end. Note this is NOT indented.  It must be all theway to the leftmain()      Run your program to be sure it still works.3) Define a getInteger() function to get the number from the user.Add it on the next to the last line of the program, right above the call to main()def getInteger()number = int(input("Enter a number between 1 and 10: "))return numberModify the main() function to call getInteger() rather than getting the number directlyfrom the user using:   number = getInteger()If necessary, replace the variable number with whatever variable you were using to holdthe number.Run your program to be sure it still works.4) Next put all the computation into its own function.On the next to the last line of the program, right above the call to main(), adddef printRomanNumeral(number)Cut all of the computation from your main() function and paste it here.Underneath the call to getInteger()  in your main function, enter          printRomanNumeral(number).  At this point your main function should be just two lines - something like this:def main()       number = getInteger()       printRomanNumeral(number)Test the program to be sure it still works

Random Star Patterns


1) Write a program that asks the user for a number (integers between 1 and 15, then uses a loop to

display the same number of adjacent stars (asterisks). Put this in a loop that repeats 5 times. For

example, if user enters 5, 9, 3, 11, and 8, your output should look like:

How many? 5


How many? 9


How many? 3


How many? 11


How many? 8


2)  Modify the program to use random numbers instead of getting numbers from the user. Add

this to the top of the file (just below the header comment)

import random

Now rather than getting each of the five numbers from the user, get them using

number = random.randint(1, 50)

Change the program so it prints 50 lines of stars instead of 5

import randomfor i in range(50):number = random.randint(1, 50)for j in range(number):print('*', end = '')print('')
Show more
Ask a Question