Python Scripts Please read the file carefully. I need it to be simple codes. Please use simple codes and not complicated ones Problem 1: (30 points) V

Python Scripts Please read the file carefully.

I need it to be simple codes. Please use simple codes and not complicated ones

Problem 1: (30 points) Variables, input/output, lists, conditions, loops.

Write a Python program that creates a list of 10 random numbers. The program then prints two sub-lists; the first containing the odd numbers and the second containing the even numbers from the randomly generated list.

Sample Output:

> The generated list is [10,17,20,99,35,71,1,33,96,9]

The sub-list of ODD numbers is

[17,99,35,71,1,33,9]

The sub-list of EVEN numbers is

[10,20,96]

Part 2: (35 Points) Modules, input/output, loops:

Write a Python program that reads two numbers N and T from the user. The program then prints the numbers 1 to N on the screen with T-second delay between every two numbers. For example, it prints “1”, then after T seconds, it prints “2”, and so on. Additionally, the program must print the current time with every number.

Hint: You may use the Python module called “time”.

Sample Output:

> Enter a number N: 4

> Enter a period T (sec): 3

1 (current time: 18:10:23)

2 (current time: 18:10:26)

3 (current time: 18:10:29)

4 (current time: 18:10:32)

Part 3: (35 Points) Modules, functions:

Write a Python program to plot the following function

( )= 2+ ( ) 0≤ ≤10.

The plot must be smooth so use small step size. You must properly label both axes and provide a title for the plot. You must define a Python function called “y” that takes an input and returns the value ( ).

Hint: Use the Python modules called “math” and “matplotlib”.

Submit a Comment

Open chat