CS-1064 Q3

0.0(0)
Studied by 0 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/22

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 8:23 PM on 4/3/24
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai
Chat

No analytics yet

Send a link to your students to track their progress

23 Terms

1
New cards

Escape Sequences

An escape sequence is a combination of characters preceded by a backslash (`\`) used to represent special characters within strings.

2
New cards

\n

It represents a newline character, which moves the cursor to the beginning of the next line.

3
New cards

\t

By using the escape sequence \t, which inserts a tab.

4
New cards

\'

By using the escape sequence __ to represent a single quote within a string.

5
New cards

\\

By using the escape sequence __ to represent a backslash character within a string.

6
New cards

Comprehensions

____ are concise ways to create sequences such as lists, dictionaries, and sets.

7
New cards

List Comprehension

By using square brackets (`[]`) enclosing an expression followed by a for clause, like [x**2 for x in range(10)].

8
New cards

Dictionary Comprehension

A ___ comprehension returns a dictionary created from an expression and a for loop within curly braces (`{}`).

9
New cards

Set Comprehension

By using curly braces (`{}`) enclosing an expression followed by a for clause, like {x**2 for x in range(10)}.

10
New cards

Dictionaries

A _______is an unordered collection of items, where each item is a key-value pair.

11
New cards

Accessing Values

By specifying the key within square brackets (`[]`), like my_dict['key1'].

12
New cards

Adding Key-Value Pair

By assigning a value to a new key, like my_dict['key3'] = 'value3'.

13
New cards

Removing Key-Value Pair

By using the del keyword followed by the dictionary name and the key to be deleted, like del my_dict['key2']. Alternatively using the .pop() method

14
New cards

Sets

A ___ is an unordered collection of unique elements.

15
New cards

Adding Element

By using the add() method, like my_set.add(4).

16
New cards

Removing Element

By using the remove() method, like my_set.remove(3).

17
New cards

Union of Sets

The | operator, like set1 | set2.

18
New cards

Objects/Classes

A class is a blueprint for creating objects in Python.

19
New cards

Defining a Class

By using the class keyword followed by the class name and a colon, like class MyClass:.

20
New cards

__init__ Method

It is a special method called the constructor, used to initialize objects of the class.

21
New cards

Creating an Object

By calling the class name followed by parentheses and any required arguments, like obj1 = MyClass(5).

22
New cards

Inheritance


___ is the mechanism of basing a new class on an existing class, inheriting its attributes and methods.

23
New cards

Encapsulation

By using private variables, indicated by prefixing variable names with double underscores __.