Garantie de satisfaction à 100% Disponible immédiatement après paiement En ligne et en PDF Tu n'es attaché à rien 4.2 TrustPilot
logo-home
Resume

Summary Final cheat-sheet

Note
-
Vendu
-
Pages
3
Publié le
17-07-2024
Écrit en
2023/2024

This document contains

Établissement
Cours








Oups ! Impossible de charger votre document. Réessayez ou contactez le support.

École, étude et sujet

Établissement
Cours
Cours

Infos sur le Document

Publié le
17 juillet 2024
Fichier mis à jour le
17 juillet 2024
Nombre de pages
3
Écrit en
2023/2024
Type
Resume

Sujets

Aperçu du contenu

Indexing and range (starting from 0 by default)
○ [start (inclusive) : end (exclusive) : stepsize (optional)] = [0, 1, 2, 3] = [-4, -3, -2, -1]. Tip: end - start is the number of elements returned.
○ Range(start (inclusive), stop (exclusive), stepsize). Range(3): 0, 1, 2. The start, stop and step parameters work the same as in list slicing.
○ Set function is used to create a set, particularly useful for removing duplicates from a list or character returns as { }. There is no order.
○ 1: 8: 3 is going to give us: 1, 4 and 7!


Scope (local and global names)
○ Global variables are defined outside functions and are accessible everywhere, but a local variable with the same name inside a function take
precedence (dominates). If a variable isn’t found locally, only then Python looks in the global scope. The global keyword allows modifying
global variables within functions.


String methods (immutable, all of these methods are non-mutating string methods)
○ Escape characters can also be used to include quotes or specific characters: \\ = \, \’ = ‘, \” = “, \n = go to the next line, \t = insert a tab.
○ The individual character(s) of a string can be accessed directly using zero based indexing just like with lists.
○ str.index(value, start, end) – returns the index of the first occurrence of the specified value within the slice (works with strings too)
○ len(x) – returns the number of elements in a list or the number of characters in a string, including spaces, punctuation and other characters.
○ sorted(x) – returns a new list containing all items from x in ascending order. When reverse = True it returns a new list containing all items
from x in descending order. Sorted( ) does not change the original list itself. Works with strings too.
○ str.capitalize( ) – returns a copy of the string with only the first character capitalized and the rest lowercase. It doesn’t change the string, but
returns a new string. You must give that new string a name else you cannot use it in the print statement.
○ str.upper( ) – returns a copy of the string with all alphabetic characters converted to uppercase, leaving the original string unchanged.
○ str.lower( ) – returns a copy of all the characters of the string converted to lowercase.
○ str.isupper( ) – returns True if all characters in the string are uppercase, otherwise it returns False, str.islower( ) it is vice versa.
€7,99
Accéder à l'intégralité du document:

Garantie de satisfaction à 100%
Disponible immédiatement après paiement
En ligne et en PDF
Tu n'es attaché à rien

Faites connaissance avec le vendeur
Seller avatar
EBEdocuments
4,5
(2)

Document également disponible en groupe

Faites connaissance avec le vendeur

Seller avatar
EBEdocuments Universiteit van Amsterdam
S'abonner Vous devez être connecté afin de suivre les étudiants ou les cours
Vendu
7
Membre depuis
5 année
Nombre de followers
5
Documents
20
Dernière vente
7 mois de cela

4,5

2 revues

5
1
4
1
3
0
2
0
1
0

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