Legibilidad
Problema a resolver
Escribe, en un archivo llamado readability.py
en una carpeta llamada sentimental-readability
, un programa que primero le pida al usuario que escriba algún texto y luego muestre el nivel educativo para el texto, de acuerdo con la fórmula de Coleman-Liau, exactamente como lo hiciste en Conjunto de problemas 2, excepto que esta vez tu programa debe estar escrito en Python.
Demostración
Especificaciones
- Recuerda que el índice de Coleman-Liau se calcula como
0.0588 * L - 0.296 * S - 15.8
, dondeL
es el número promedio de letras por cada 100 palabras en el texto yS
es el número promedio de oraciones por cada 100 palabras en el texto. - Usa
get_string
de la biblioteca CS50 para obtener la entrada del usuario yprint
para mostrar tu respuesta. - Tu programa debe contar el número de letras, palabras y oraciones en el texto. Puedes asumir que una letra es cualquier carácter en minúsculas de
a
az
o cualquier carácter en mayúsculas deA
aZ
, cualquier secuencia de caracteres separada por espacios debe contar como una palabra y que cualquier aparición de un punto, un signo de exclamación o un signo de interrogación indican el final de una oración. - Tu programa debe imprimir como resultado
"Grado X"
dondeX
es el nivel educativo calculado mediante la fórmula de Coleman-Liau, redondeado al entero más cercano. - Si el número del índice resultante es 16 o superior (equivalente a un nivel educativo de licenciatura avanzada o superior), tu programa debe mostrar
"Grado 16+"
en lugar de dar el número exacto del índice. Si el número del índice es menor que 1, tu programa debe mostrar"Antes del Grado 1"
.
Cómo probar
Mientras que check50
está disponible para este problema, te recomendamos que primero pruebes tu código por tu cuenta para cada uno de los siguientes.
- Ejecuta tu programa como
python readability.py
y espera una solicitud de entrada. EscribeOne fish. Two fish. Red fish. Blue fish.
y presiona enter. Tu programa debe mostrarBefore Grade 1
. - Ejecuta tu programa como
python readability.py
y espera una solicitud de entrada. EscribeWould you like them here or there? I would not like them here or there. I would not like them anywhere.
y presiona enter. Tu programa debe mostrarGrade 2
. - Ejecuta tu programa como
python readability.py
y espera una solicitud de entrada. EscribeCongratulations! Today is your day. You're off to Great Places! You're off and away!
y presiona enter. Tu programa debe mostrarGrade 3
. - Ejecuta tu programa como
python readability.py
y espera una solicitud de entrada. EscribeHarry Potter was a highly unusual boy in many ways. For one thing, he hated the summer holidays more than any other time of year. For another, he really wanted to do his homework, but was forced to do it in secret, in the dead of the night. And he also happened to be a wizard.
y presiona enter. Tu programa debe mostrarGrade 5
. - Ejecuta tu programa como
python readability.py
y espera una solicitud de entrada. EscribeIn my younger and more vulnerable years my father gave me some advice that I've been turning over in my mind ever since.
y presiona enter. Tu programa debe mostrarGrade 7
. - Ejecuta tu programa como
python readability.py
y espera una solicitud de entrada. EscribeAlice was beginning to get very tired of sitting by her sister on the bank, and of having nothing to do: once or twice she had peeped into the book her sister was reading, but it had no pictures or conversations in it, "and what is the use of a book," thought Alice "without pictures or conversation?"
y presiona enter. Tu programa debe mostrarGrade 8
. - Ejecuta tu programa como
python readability.py
y espera una solicitud de entrada. EscribeWhen he was nearly thirteen, my brother Jem got his arm badly broken at the elbow. When it healed, and Jem's fears of never being able to play football were assuaged, he was seldom self-conscious about his injury. His left arm was somewhat shorter than his right; when he stood or walked, the back of his hand was at right angles to his body, his thumb parallel to his thigh.
y presiona enter. Tu programa debe mostrarGrade 8
. - Ejecuta tu programa como
python readability.py
y espera una solicitud de entrada. EscribeThere are more things in Heaven and Earth, Horatio, than are dreamt of in your philosophy.
y presiona enter. Tu programa debe mostrarGrade 9
. - Ejecuta tu programa como
python readability.py
y espera una solicitud de entrada. EscribeIt was a bright cold day in April, and the clocks were striking thirteen. Winston Smith, his chin nuzzled into his breast in an effort to escape the vile wind, slipped quickly through the glass doors of Victory Mansions, though not quickly enough to prevent a swirl of gritty dust from entering along with him.
y presiona enter. Tu programa debe mostrarGrade 10
. - Ejecuta tu programa como
python readability.py
y espera una solicitud de entrada. EscribeA large class of computational problems involve the determination of properties of graphs, digraphs, integers, arrays of integers, finite families of finite sets, boolean formulas and elements of other countable domains.
y presiona enter. Tu programa debe mostrarGrade 16+
.
Corrección
check50 cs50/problems/2024/x/sentimental/readability
Estilo
style50 readability.py
Cómo enviar
submit50 cs50/problems/2024/x/sentimental/readability