Rédigé par des étudiants ayant réussi Disponible immédiatement après paiement Lire en ligne ou en PDF Mauvais document ? Échangez-le gratuitement 4,6 TrustPilot
logo-home
Examen

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

Note
-
Vendu
-
Pages
29
Publié le
10-12-2024
Écrit en
2024/2025

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

Établissement
Python Coding
Cours
Python Coding

Aperçu du contenu

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.

École, étude et sujet

Établissement
Python Coding
Cours
Python Coding

Infos sur le Document

Publié le
10 décembre 2024
Nombre de pages
29
Écrit en
2024/2025
Type
Examen
Contenu
Inconnu

Sujets

15,60 €
Accéder à l'intégralité du document:

Mauvais document ? Échangez-le gratuitement Dans les 14 jours suivant votre achat et avant le téléchargement, vous pouvez choisir un autre document. Vous pouvez simplement dépenser le montant à nouveau.
Rédigé par des étudiants ayant réussi
Disponible immédiatement après paiement
Lire en ligne ou en PDF

Faites connaissance avec le vendeur

Seller avatar
Les scores de réputation sont basés sur le nombre de documents qu'un vendeur a vendus contre paiement ainsi que sur les avis qu'il a reçu pour ces documents. Il y a trois niveaux: Bronze, Argent et Or. Plus la réputation est bonne, plus vous pouvez faire confiance sur la qualité du travail des vendeurs.
saraciousstuvia WALDEN UNIVERSITY
S'abonner Vous devez être connecté afin de pouvoir suivre les étudiants ou les formations
Vendu
562
Membre depuis
3 année
Nombre de followers
380
Documents
11347
Dernière vente
3 semaines de cela
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

114 revues

5
61
4
20
3
17
2
3
1
13

Récemment consulté par vous

Pourquoi les étudiants choisissent Stuvia

Créé par d'autres étudiants, vérifié par les avis

Une qualité sur laquelle compter : rédigé par des étudiants qui ont réussi et évalué par d'autres qui ont utilisé ce document.

Le document ne convient pas ? Choisis un autre document

Aucun souci ! Tu peux sélectionner directement un autre document qui correspond mieux à ce que tu cherches.

Paye comme tu veux, apprends aussitôt

Aucun abonnement, aucun engagement. Paye selon tes habitudes par carte de crédit et télécharge ton document PDF instantanément.

Student with book image

“Acheté, téléchargé et réussi. C'est aussi simple que ça.”

Alisha Student

Foire aux questions