100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached 4.2 TrustPilot
logo-home
Exam (elaborations)

C:pythonPython Programmingweek 5

Rating
-
Sold
-
Pages
3
Grade
A+
Uploaded on
22-07-2023
Written in
2022/2023

1. 1. A palindrome is a word or a phrase that reads the same way backwards as forwards. Write a function that accepts a text string as input and determines whether or not the text string is a palindrome. Then write a program “Lab5B” that uses this function. Prompt the user to enter a word or phrase and then inform the user whether or not the text entered qualifies as a palindrome. [Hint: there is a REVERSE method for a string. But to compare a string reversed this way, you need to convert to list: if list(str) == list(rev_str):] 2. 1. Write a Python program (its name must be “Lab5B”) that generates a sequence/list of unique prime numbers (a prime number is only evenly divisible by itself and 1, for example, 5, 7, 11, 13 are prime numbers). Specifically, the program must meet the following detailed requirements: 1. Define a function, is_prime(n), which return True if n is a prime number, otherwise return False. 2. Define a function, generate_random_number(n1, n2), which return a prime number that is between n1 and n2 inclusive. (Hint: use nt(n1, n2) to generate a random number). Define a function, number_of_primes_in_the_range(n1, n2), which return the total number of prime numbers in the range [n1, n2]. The program must first read input of 3 integers in a single line (i.e., a string consisting of 3 integers separated by space): a. the first integer defines the number of prime numbers to be generated; b. the second and third integers inclusive defines the range of those prime numbers; c. the program must check the 3 integers to make sure these integers are provided correctly; if not, the program must keep reading and checking the input to make sure they are correct—use the following demo outputs for your reference; d. the program may not read the 3 integers one by one; e. (hints: use the above defined function number_of_primes_in_the_range(n1, n2) to examine whether the 1st integer in the input is correct.) f. (hints: you may find the example given at The program outputs the sequence/list of unique prime numbers as defined by the input with use of the above defined functions. The program outputs the prime number in reversed order, sorted order, and finally the minimum and maximum prime numbers—use the following demos as your design and implementation of this project.

Show more Read less
Institution
Python Programming
Course
Python Programming








Whoops! We can’t load your doc right now. Try again or contact support.

Written for

Institution
Python Programming
Course
Python Programming

Document information

Uploaded on
July 22, 2023
Number of pages
3
Written in
2022/2023
Type
Exam (elaborations)
Contains
Questions & answers

Subjects

Get to know the seller

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
datascience24 Self
View profile
Follow You need to be logged in order to follow users or courses
Sold
84
Member since
3 year
Number of followers
16
Documents
159
Last sold
1 month ago

Please message me using Send Message option for new assignment requests.

4.5

12 reviews

5
10
4
0
3
1
2
0
1
1

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Frequently asked questions