Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Summary

Summary Midterm cheat-sheet

Rating
-
Sold
1
Pages
5
Uploaded on
17-07-2024
Written in
2023/2024

This document contains the cheat-sheet used during the midterm exam. Using this cheat-sheet I obtained a grade of 8/10 for my midterm. I advise you to use this cheat-sheet as a reference and put it in your own words.

Institution
Module

Content preview

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 { }.

Slicing (for lists, strings and tuples)
○ To copy a list in Python and ensure that changes to the new list do not affect the original list, you can use the list( ) or copy( ) functions, or
create a copy of a list by slicing it from the beginning to the end x[ : ] or x[ : : ]. Do not use the equal to sign to copy lists.
○ With positive steps you go from the start index to the right, with negative steps you go from the end to the left.
○ [ : : -1] reverses the list. [ : index] starts from index zero. [index : ] ends at, including the last element.

Importing packages – import package (as nickname). If you want to make your import more selective use – from package import function.

Functions
○ A function in Python is an object that encapsulates executable code, which can
be invoked by its name. Functions are defined with parameters in their headers,
and when called, arguments are passed to these parameters.
○ It may return a value using a return statement; if no return statement is
executed, None is returned by default.
○ Python fills any explicitly defined parameters first with the provided arguments.

Written for

Institution
Study
Module

Document information

Uploaded on
July 17, 2024
File latest updated on
July 17, 2024
Number of pages
5
Written in
2023/2024
Type
SUMMARY

Subjects

£5.83
Get access to the full document:

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Get to know the seller
Seller avatar
EBEdocuments
4.5
(2)

Also available in package deal

Get to know the seller

Seller avatar
EBEdocuments Universiteit van Amsterdam
Follow You need to be logged in order to follow users or courses
Sold
7
Member since
5 year
Number of followers
5
Documents
20
Last sold
10 months ago

4.5

2 reviews

5
1
4
1
3
0
2
0
1
0

Trending documents

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their exams and reviewed by others who've used these revision notes.

Didn't get what you expected? Choose another document

No problem! You can straightaway pick a different document that better suits what you're after.

Pay as you like, start learning straight away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and smashed it. It really can be that simple.”

Alisha Student

Frequently asked questions