Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Exercise 5.1 (navigate2 py). Modify navigate-py from lab 3 so that, instead of performing each action as it is entered, the program accepts user input

image text in transcribed
Exercise 5.1 (navigate2 py). Modify navigate-py from lab 3 so that, instead of performing each action as it is entered, the program accepts user input without drawing anything until the "stop" command is given all while ignoring invalid inputs. After the user finishes, the program should run the drawing commands all at once There are many ways to approach this problem. One way is to accept the user's input and append the strings to a list. For example, if the user enters "forward, left, 50, forward, right, 20, forward, stop," you might have the following list forvard', "left.50, "foruard', "right20 'forvard' Exercise 5.2 (statistics107 py). Write the functions listed below. They should that take a list as a parameter and return the following numbers. Use the provided statistics107 py to write and test your functions nax elenents) maximum element. nin(elenents) minimum element. eun(elesente) the sum of every element in the list. Although you may find them useful for testing, do not use the built-in functions ax, nin, Also, write the following functions that take a list and return a list with the following elements: odds(elements) all odd elements of the input list. evens (elenents) all even elements every other (elenents) finds every other element, starting from the o overy other odd Celonents) finds every other element then returns only the odd elements. every other even(elements) finds every other element then returns only the even elements. You do not need to accept user input, just write the functions and use the function run-testa to check them Remember you can call your own functions from any part of your program, even from other functions that you write. The goal is to reduce repetition. What's the minimum amount of code you'll have to write? import statiatics107 statistics107 every otherCt1,2,3,41) 1, 3 >statistics107 every other eves(, 100, 45, 23, 10. 2, 4, 13) 12 CSE/IT 1071 Lab 4: Lists and For s(100, 2 estatistice107 evenstti,2,3,41) atatiatice107.un E1,2,3,4]) >>> aun([1,2,3,4]) # write your own, Exercise 5.1 (navigate2 py). Modify navigate-py from lab 3 so that, instead of performing each action as it is entered, the program accepts user input without drawing anything until the "stop" command is given all while ignoring invalid inputs. After the user finishes, the program should run the drawing commands all at once There are many ways to approach this problem. One way is to accept the user's input and append the strings to a list. For example, if the user enters "forward, left, 50, forward, right, 20, forward, stop," you might have the following list forvard', "left.50, "foruard', "right20 'forvard' Exercise 5.2 (statistics107 py). Write the functions listed below. They should that take a list as a parameter and return the following numbers. Use the provided statistics107 py to write and test your functions nax elenents) maximum element. nin(elenents) minimum element. eun(elesente) the sum of every element in the list. Although you may find them useful for testing, do not use the built-in functions ax, nin, Also, write the following functions that take a list and return a list with the following elements: odds(elements) all odd elements of the input list. evens (elenents) all even elements every other (elenents) finds every other element, starting from the o overy other odd Celonents) finds every other element then returns only the odd elements. every other even(elements) finds every other element then returns only the even elements. You do not need to accept user input, just write the functions and use the function run-testa to check them Remember you can call your own functions from any part of your program, even from other functions that you write. The goal is to reduce repetition. What's the minimum amount of code you'll have to write? import statiatics107 statistics107 every otherCt1,2,3,41) 1, 3 >statistics107 every other eves(, 100, 45, 23, 10. 2, 4, 13) 12 CSE/IT 1071 Lab 4: Lists and For s(100, 2 estatistice107 evenstti,2,3,41) atatiatice107.un E1,2,3,4]) >>> aun([1,2,3,4]) # write your own

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

Object Databases The Essentials

Authors: Mary E. S. Loomis

1st Edition

020156341X, 978-0201563412

More Books

Students also viewed these Databases questions

Question

Show that standard Brownian motion is a Martingale.

Answered: 1 week ago

Question

Develop clear policy statements.

Answered: 1 week ago

Question

Draft a business plan.

Answered: 1 week ago

Question

Describe the guidelines for appropriate use of the direct plan.

Answered: 1 week ago