100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached
logo-home
Summary Final cheat-sheet $8.64
Add to cart

Summary

Summary Final cheat-sheet

 19 views  0 purchase
  • Course
  • Institution

This document contains

Last document update: 5 months ago

Preview 1 out of 3  pages

  • July 17, 2024
  • July 17, 2024
  • 3
  • 2023/2024
  • Summary
avatar-seller
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.

The benefits of buying summaries with Stuvia:

Guaranteed quality through customer reviews

Guaranteed quality through customer reviews

Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.

Quick and easy check-out

Quick and easy check-out

You can quickly pay through credit card or Stuvia-credit for the summaries. There is no membership needed.

Focus on what matters

Focus on what matters

Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!

Frequently asked questions

What do I get when I buy this document?

You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.

Satisfaction guarantee: how does it work?

Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.

Who am I buying these notes from?

Stuvia is a marketplace, so you are not buying this document from us, but from seller EBEdocuments. Stuvia facilitates payment to the seller.

Will I be stuck with a subscription?

No, you only buy these notes for $8.64. You're not tied to anything after your purchase.

Can Stuvia be trusted?

4.6 stars on Google & Trustpilot (+1000 reviews)

56326 documents were sold in the last 30 days

Founded in 2010, the go-to place to buy study notes for 14 years now

Start selling
$8.64
  • (0)
Add to cart
Added