100% tevredenheidsgarantie Direct beschikbaar na je betaling Lees online óf als PDF Geen vaste maandelijkse kosten
logo-home
Summary Introduction to Python Codes $4.47
In winkelwagen

Samenvatting

Summary Introduction to Python Codes

1 beoordeling
 11 keer verkocht
  • Vak
  • Instelling
  • Boek

This contains relevant lines of codes and commands as well as examples for the material of Introduction to Python. This summary does not include theoretical or conceptual parts. This document might be especially useful because it is an allowed exam material, i.e. one can use it during the exam and ...

[Meer zien]

Voorbeeld 2 van de 6  pagina's

  • Ja
  • 25 mei 2021
  • 6
  • 2020/2021
  • Samenvatting

1  beoordeling

review-writer-avatar

Door: julianzalme • 3 jaar geleden

avatar-seller
% == 0 → no remainder of division x = “….”

// → highest possible value of div. (floor division) x.upper()

print(“…..” * x) → prints string is x = True x.replace(x, y) → x = what to replace, y = replace

X = (….) → Tuple, works same as list with what

x[…] → value of that position x.capitalize()

x.index(…) → position of that value x.count()

print( i in x) → prints True if possible x.index()

Adding to a list: x.find()

X = [….] x.format()

x.append(….) → with lists or strings Stride:

x = x + [….] my_string[ : : ] → start : end : incrementation

x.extend(….) my_string[ : : -1] → prints string in reverse

x += 1 Splitting:

x += x my_string.split( sep= …., maxsplit = ….)

sum += element sep = where should it be split up

sum = element += element maxsplit → 0 – indexing

Deleting an item: rsplit → starts from the back (right)

del x(….) \n → new line is started

del(x[….]) my_string.splitlines() → splits where is space

x.remove(…) Joining:

Copying a list: sep.join(iterable)

Y = x.copy(…) sep = what should it be separated with i.e. “ “

Y = x[ : ] Stripping:

Rounding: my_string.strip() → removes 1st and last character

round( x, y) → x = number to round, y = decimals or whatever is specified in ( )

format( x, .2f) → float with 2 decimals

format( x, “.2f”)

String methods

, Find substrings: f = float

my_string.find( substring, start, end) !s = string

→ substring = what should be found !r = string with “ “

Start, end → index positions Datetime f – string:

i.e. i.e. print(f” Today is {today: %B, %d, %y}”)

for i in x: in-line function like lambda:
try:
print(i.find(….)) num1 = …
except Value Error:
print(…) num2 = …

print(f”{num1} plus {num2} is {num1 + num2}”)
Print words on separate lines:
or with functions:
X=“…“
def main(num1, num2)
for word in x.split():
return num1 + num2
print(x)
print(f” … is {main(10, 20}”)
String Formatting:
Template method
Positional Formatting:
from string import Template
“text { } “.format(values to be included)
→ using $ as placeholder
print(“ text { } … .format(string1, string2 …)”)
(1) Create template
with index:
→ string1 = Template(“… $identifier .. “)
print(“ {index 1} … {index 2..}”.format(strings1 ..)”)
(2) Fill identifier variable
Placeholders with dictionary:
→ string1.substitute(identifier=”…..”)
dict1 = {key1: value1, key2: value2}
Use ${identifier} when elements are directly on
print(“{data[key1]} … “.format(data = dict1))
string1.safe_substitute(…) → only fills where
specify inside placeholder which format
possible, unfilled identifiers are unchanged
→ {index: format}
i=…
f – strings:
i.isnumeric() → if True then ..
f”literal string {expression}

print(f” …. {expression1} …)

here als {expression: format}

format → d = digit (integer)

Dit zijn jouw voordelen als je samenvattingen koopt bij Stuvia:

Bewezen kwaliteit door reviews

Bewezen kwaliteit door reviews

Studenten hebben al meer dan 850.000 samenvattingen beoordeeld. Zo weet jij zeker dat je de beste keuze maakt!

In een paar klikken geregeld

In een paar klikken geregeld

Geen gedoe — betaal gewoon eenmalig met iDeal, creditcard of je Stuvia-tegoed en je bent klaar. Geen abonnement nodig.

Direct to-the-point

Direct to-the-point

Studenten maken samenvattingen voor studenten. Dat betekent: actuele inhoud waar jij écht wat aan hebt. Geen overbodige details!

Veelgestelde vragen

Wat krijg ik als ik dit document koop?

Je krijgt een PDF, die direct beschikbaar is na je aankoop. Het gekochte document is altijd, overal en oneindig toegankelijk via je profiel.

Tevredenheidsgarantie: hoe werkt dat?

Onze tevredenheidsgarantie zorgt ervoor dat je altijd een studiedocument vindt dat goed bij je past. Je vult een formulier in en onze klantenservice regelt de rest.

Van wie koop ik deze samenvatting?

Stuvia is een marktplaats, je koop dit document dus niet van ons, maar van verkoper mathiasm1. Stuvia faciliteert de betaling aan de verkoper.

Zit ik meteen vast aan een abonnement?

Nee, je koopt alleen deze samenvatting voor $4.47. Je zit daarna nergens aan vast.

Is Stuvia te vertrouwen?

4,6 sterren op Google & Trustpilot (+1000 reviews)

Afgelopen 30 dagen zijn er 65539 samenvattingen verkocht

Opgericht in 2010, al 15 jaar dé plek om samenvattingen te kopen

Begin nu gratis

Laatst bekeken door jou


$4.47  11x  verkocht
  • (1)
In winkelwagen
Toegevoegd