Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Need Python help ull Verizon LTE 6:43 PM 11% 0 piazza.com 112 - Spring 2020 - Programming Assignment 4 Loops Due Date: Sunday, February 23,
Need Python help
ull Verizon LTE 6:43 PM 11% 0 piazza.com 112 - Spring 2020 - Programming Assignment 4 Loops Due Date: Sunday, February 23, 11:59pm The purpose of this assignment is to get practice with loops See the "assignment basics" file for more detailed information about getting assistance, running the test file, grading, commenting, and many other extremely important things. Each assignment is governed by the rules in that document. https://plazza.com/class_profile/get_resource/k4wblafqtoj2cx/k5x3ennufm34cg. Needed file: the tester for this assignment tester 4.py https://plazza.com/class_profile/get_resource/k4wblafto2cx/k6rgib2ngsq3ar Background Loops allow us to run the same block of code multiple times in a row. When variables used in that block of code are changed between iterations, we can accumulate effects and process larger batches of data, such as the elements in a sequence (e.g. list, string, file, etc.). There are problems that selection statements alone are insufficient to solve; yet loops add enough power to tackle them. We will use loops to solve various problems. Guidelines You must have at least one loop in each function, You are not allowed to import anything. From built-in functions, you are allowed to call int() and range() only. You are not allowed to use strings, lists, tuples, sets, dictionaries You are not allowed to use anything that hasn't been covered in class (e.g. list comprehension) Don't forget to review the "assignment basics" file Insert comments in the lines you deem necessary unt_moves (start, end, step) Description: It counts how many moves you need to get from start to end with a step of step by following two rules: 1) if a move lands you on a number ending with 3 or 5 your step is increased by 3 or 5 respectively, 2) if a move lands you on a number ending with 7 or 8 you're automatically transferred ahead by 7 or 8 positions respectively and this transfer doesn't count as a move neither as a landing on a new number. The last move can land either on end or any number larger than this. Parameters: start(int), end (int), step (int) are all positive. end is larger or equal to start. Return value: int Examples: count_moves (1, 30, 1) count_moves (2, 17, 2) 5 # 1 + 2 + 3 + 7 ~ 14 18 26 30 # 2 + 4 + 6 + 8 ~ 16 + 18 Il Verizon LTE 6:44 PM piazza.com 9% O # count moves tests - 18pts def test_count_moves_1 (self):self.assertEqual(count moves (1, 30, 1), 5) def test_count_moves_2 (self):self.assertEqual (count moves (2, 17, 2), 4) def test_count_moves_3 (self):self.assertEqual (count_moves (1, 37, 2), 7) def test count moves 4 (self):self.assertEqual (count_moves (5, 43, 3), 6) def test count moves 5 (self):self. assertEqual(count moves (18 , 20, 3), 1) def test count moves 6 (self):self.assertEqual (count moves (49 ,517, 4), 25) def test count moves 7 (self):self.assertEqual(count moves (34 , 318, 5), 57) def test_count_moves_8 (self):self.assertEqual (count_moves (3, 347, 6), 21) def test_count_moves_9 (self):self.assertEqual(count moves (4, 735, 7), 31) def test count moves 10 (self):self.assertEqual (count moves (23 , 40, 8), 3) def test_count_moves_11 (self):self.assertEqual (count_moves (17 , 299, 9), 15) def test count moves 12 (self):self.assertEqual(count_moves (35 2, 105310, 71)Step 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