Question: To work with loops ( for and while), assertions, break and continue in python. Assignment: Ask the user to enter two numeric values, Both values
To work with loops ( for and while), assertions, break and continue in python.
Assignment:
Ask the user to enter two numeric values,
-
Both values must be stored as minimum and maximum values. Use assert syntax to check if the second value is larger than the first value.
[assert min
-
Print the odd numbers between those two values using while loop.
-
Print the prime numbers between those two values using while loop.
-
Using a for loop, print the number(s) between those two values incrementing by 2.
-
Print the numbers from the range mentioned above using for loop incrementing by 2 while skipping the multiples of 3 by using continue.
-
For this part, please check the following steps:
-
a) Assign a list of 10 different numeric values in your code that must include a value
5 (any 10 values, not entered by user).
-
b) Find the product of all numbers in the list that occur before 5. Break the loop when
5 is found.
-
c) Print the product value found in step b) and the index of the 5 in the list.
For example: (Do not use this example in your code). List = [1,2,3,4,5,6,7,8,9,1] Product = 24 Index found at 4.
Note: The list should have 2-digit and 3-digit numbers as well and it must include a 5.
-
To be done using Python 3
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
