• ¿Documento equivocado? Cámbialo gratis
  • Escrito por estudiantes que aprobaron
  • Inmediatamente disponible después del pago
  • Leer en línea o como PDF
Vender
¿Dónde estudias?
Tu idioma
Document preview thumbnail
Vista previa 1 fuera de 3 páginas
Examen

C:pythonPython Programmingweek 5

Document preview thumbnail
Vista previa 1 fuera de 3 páginas

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.


Información del documento

Subido en
22 de julio de 2023
Número de páginas
3
Escrito en
2022/2023
Tipo
Examen
Contiene
Preguntas y respuestas
$15.99

¿Documento equivocado? Cámbialo gratis Dentro de los 14 días posteriores a la compra y antes de descargarlo, puedes elegir otro documento. Puedes gastar el importe de nuevo.
Escrito por estudiantes que aprobaron
Inmediatamente disponible después del pago
Leer en línea o como PDF

Seller avatar
Los indicadores de reputación están sujetos a la cantidad de artículos vendidos por una tarifa y las reseñas que ha recibido por esos documentos. Hay tres niveles: Bronce, Plata y Oro. Cuanto mayor reputación, más podrás confiar en la calidad del trabajo del vendedor.
datascience24
4.5
(12)
Vendido
87
Seguidores
16
Artículos
159
Última venta
6 meses hace




Por qué los estudiantes eligen Stuvia

Creado por compañeros estudiantes, verificado por reseñas

Calidad en la que puedes confiar: escrito por estudiantes que aprobaron y evaluado por otros que han usado estos resúmenes.

¿No estás satisfecho? Elige otro documento

¡No te preocupes! Puedes elegir directamente otro documento que se ajuste mejor a lo que buscas.

Paga como quieras, empieza a estudiar al instante

Sin suscripción, sin compromisos. Paga como estés acostumbrado con tarjeta de crédito y descarga tu documento PDF inmediatamente.

Student with book image

“Comprado, descargado y aprobado. Así de fácil puede ser.”

Alisha Student

Preguntas frecuentes

Ups! No podemos cargar tu documento ahora. Inténtalo de nuevo o contacta con soporte.