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,

  1. 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

  2. Print the odd numbers between those two values using while loop.

  3. Print the prime numbers between those two values using while loop.

  4. Using a for loop, print the number(s) between those two values incrementing by 2.

  5. Print the numbers from the range mentioned above using for loop incrementing by 2 while skipping the multiples of 3 by using continue.

  6. For this part, please check the following steps:

    1. 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).

    2. b) Find the product of all numbers in the list that occur before 5. Break the loop when

      5 is found.

    3. 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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!