Escrito por estudiantes que aprobaron Inmediatamente disponible después del pago Leer en línea o como PDF ¿Documento equivocado? Cámbialo gratis 4,6 TrustPilot
logo-home
Examen

PYTHON CODING QUESTIONS AND ANSWERS TO HELP IN (Problem Solving & Understanding) 100% VERIFIED

Puntuación
-
Vendido
-
Páginas
29
Subido en
10-12-2024
Escrito en
2024/2025

PYTHON CODING QUESTIONS AND ANSWERS TO HELP IN (Problem Solving & Understanding) 100% VERIFIED

Institución
Python Coding
Grado
Python Coding

Vista previa del contenido

PYTHON CODING QUESTIONS AND
ANSWERS TO HELP IN (Problem Solving
& Understanding) 100% VERIFIED .
What is indexing used for in Python?
"Indexing" is used when referring to an element of an inerrable by its position within
the inerrable. This is done through indexing [ ].
CQ: Try creating a substring based off of the first word or name in the sentence.

use the following variable:

name = "Johnny Appleseed"

Once finished.

Try creating a substring based off of the last word or name in the sentence.

Once finished.

Next, create a weird name from the variable by leaving the first and last name in
but making it so it skips every other letter.

Lastly, reverse the name or text of the value in the variable by making it read
In order to write a line of code that can slice a specific part of the name such as
"Johnny" by itself,

We'll use the following code:

first_name = name[0:6]

or

,first_name = name[:6]

Then...

print(first_name)

Now, in order to write a line of code that can slice the last word or name such as
"Applseed".

We'll use the following code:

last_name = name[7:17]

or

last_name = name[7:]

Then...

print(last_name)

Note: For slicing we'll use the colon to snip a part of the text in the variable by listing
the number the letter starts with which is always "0" and "6" since we'll always take
an extra character at the end or you can also see it as there's 6 letters in "Johnny" but
we still always start with zero.

Next, in order to create a weird name we'll need to add a third colon instead of just
the two we've been using previously.

We'll use the following code:

funny_name = name[0:16:2]

or

, funny_name = name[::2]

print(funny_name)

Note: As you can see the program will skip every other letter in "Johnny Appleseed".

"Johnny Appleseed"
"J h n p l s e "

Lastly, in order to create a reversed name we'll use negative numbers. Similar to first
puzzle just counting starting from the last letter instead of the first.

reversed_name=[-1:-17:-1]

or

reversed_name=[::-1]

print(reversed_name)

Note: When counting backwards we'll always count in the negatives. Due to counting
in the negatives there's no need to count zero since -0 isn't an actual number so we'll
default into -1 as the first letter reversed counting backwards in the last colon.
CQ: Try removing everything but the name of from the website link from the value
in the variable.

use the following variable:

website = "https://google.com"
In order to remove everything but the name of the website we'll use the slice option.

For "Slice" it's a little bit different so we'll use a comma instead of a colon for slice
unlike the indexing.

Escuela, estudio y materia

Institución
Python Coding
Grado
Python Coding

Información del documento

Subido en
10 de diciembre de 2024
Número de páginas
29
Escrito en
2024/2025
Tipo
Examen
Contiene
Desconocido

Temas

$17.49
Accede al documento completo:

¿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

Conoce al vendedor

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.
saraciousstuvia WALDEN UNIVERSITY
Ver perfil
Seguir Necesitas iniciar sesión para seguir a otros usuarios o asignaturas
Vendido
563
Miembro desde
3 año
Número de seguidores
380
Documentos
11347
Última venta
2 días hace
BRIGHTEST IDEAS EDUCATIONAL WORLD

Welcome to the best educational world with the brightest,amazing and all complete study materials. I wish you great,easy learning and success through out your course. Kindly message me if you cant find your tutorials

4.0

115 reseñas

5
62
4
20
3
17
2
3
1
13

Documentos populares

Recientemente visto por ti

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