PRP201c_-_SU_2024_-_PE2_2580.webp
P

PRP201c_-_SU_2024_-_PE2_2580.webp

120 minutes
Exercise 1: (3 marks) Write a program that asks the user for a range (start and end) and the number of unique integers they want to generate within that range. The program should then generate that many unique integers and store them in a list.
Display the list, the number of even numbers, and the number of odd numbers.
Result of the program:
Enter the start of the range: 10
Enter the end of the range: 100
How many unique integers would you like to generate? 10
Generated list of unique integers: [50, 42, 52, 94, 29, 96, 82, 80, 48, 31]
Number of even numbers: 8
Number of odd numbers: 2
Exercise 2: (3 marks)
Write a program named filter_prime_numbers that reads a text file named integers_data.txt, extracts all prime numbers, and saves them to a new file named prime_numbers.txt.
Content of the input file (integers_data.txt):2, 13, 24, 5, 6, 27, 8, 29, 33
Content of the output file (prime numbers.txt):2, 13, 5, 29
Result of the program:
Original list of numbers: [2, 13, 24, 5, 6, 27, 8, 29, 33]
List of prime numbers: [2, 13, 5, 29]
Exercise 3: (4 marks)
Write a program that implements the following tasks:

+ 100%
Zoom
Close
Chưa có bình luận nào.

Thông tin

Category
PRP201c
Thêm bởi
precious_treasure
Ngày thêm
Lượt xem
2,062
Lượt bình luận
0
Rating
0.00 star(s) 0 đánh giá

Image metadata

Filename
PRP201c_-_SU_2024_-_PE2_2580.webp
File size
94.3 KB
Dimensions
1920px x 907px

Share this media

Back
Bên trên Bottom