Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Beginner Python code problem 3) Write a program that prompts the user to enter a character and a number. Write a function draw_line() that will
Beginner Python code problem
3) Write a program that prompts the user to enter a character and a number. Write a function draw_line() that will draw a line by repeating the input character by the number of times entered by the user. The function draw_line() is defined like the following and will return a string made up of the repetitions of the input character: def draw_line(ch, size): Sample runs This program wiII draw a Iine tor you. Enter a character: * Enter the size of the line you want to draw: 5 This program will draw a line for you. Enter a character: Enter the size of the line you want to draw: 7 4) Write a program that initializes a list of names nameList such as the below and then prompts the user to enter a name. Write a function getlndex( ) that searches and returns the index of the input or target name from the list nameList. If the name is in the list, the function will return the index of the name in the list and if the name is not in the list, the function will return 1 The list of names can be initialized as the followingg nameList = ["Dan", "Mary", "Sonia", "Joy", "Laila", "Victor", "Erin", "Shawn", "John"] The function getlndex() is defined like the following: def getlndex(name, nameList) Sample runs: Enter a name: Sonia The name Sonia is found at index 2 in the list. Enter a name: Suzie The name Sonia is found at index -1 in the listStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started