{ "@context": "https://schema.org", "@type": "Organization", "name": "Brainscape", "url": "https://www.brainscape.com/", "logo": "https://www.brainscape.com/pks/images/cms/public-views/shared/Brainscape-logo-c4e172b280b4616f7fda.svg", "sameAs": [ "https://www.facebook.com/Brainscape", "https://x.com/brainscape", "https://www.linkedin.com/company/brainscape", "https://www.instagram.com/brainscape/", "https://www.tiktok.com/@brainscapeu", "https://www.pinterest.com/brainscape/", "https://www.youtube.com/@BrainscapeNY" ], "contactPoint": { "@type": "ContactPoint", "telephone": "(929) 334-4005", "contactType": "customer service", "availableLanguage": ["English"] }, "founder": { "@type": "Person", "name": "Andrew Cohen" }, "description": "Brainscape’s spaced repetition system is proven to DOUBLE learning results! Find, make, and study flashcards online or in our mobile app. Serious learners only.", "address": { "@type": "PostalAddress", "streetAddress": "159 W 25th St, Ste 517", "addressLocality": "New York", "addressRegion": "NY", "postalCode": "10001", "addressCountry": "USA" } }

Programming Part 1 Flashcards

(27 cards)

1
Q

What are the basic data types in Python?

A

int, float, str, bool

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is a list in Python?

A

An ordered, mutable collection of items.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is a tuple in Python?

A

An ordered, immutable collection of items.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is a dictionary in Python?

A

A collection of key-value pairs.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is a set in Python?

A

An unordered collection of unique items.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is an if-statement used for?

A

To execute code conditionally based on a boolean expression.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is a for loop used for?

A

To iterate over a sequence or iterable.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is a while loop used for?

A

To repeat code while a condition is true.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What does the ‘break’ statement do?

A

It exits a loop immediately.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What does the ‘continue’ statement do?

A

It skips to the next iteration of the loop.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

How do you define a function in Python?

A

Using the ‘def’ keyword.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is the difference between a parameter and an argument?

A

A parameter is in the function definition; an argument is the value passed in.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is a return statement?

A

It sends a result back from a function to the caller.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is a lambda function?

A

An anonymous function defined with the ‘lambda’ keyword.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is a docstring?

A

A string that documents a function’s purpose, inputs, and outputs.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is list comprehension?

A

A concise way to create lists using a loop in a single line.

17
Q

How do you write a list comprehension that squares numbers?

A

[x**2 for x in numbers]

18
Q

What is dictionary comprehension?

A

Creating dictionaries using key-value pairs in a single line.

19
Q

What is a try/except block used for?

A

To handle errors without crashing the program.

20
Q

What is a common Python error when dividing by zero?

A

ZeroDivisionError

21
Q

What is a NameError?

A

An error that occurs when trying to use a variable that hasn’t been defined.

22
Q

What is a TypeError?

A

An error when an operation is applied to an object of inappropriate type.

23
Q

What does the len() function do?

A

Returns the number of items in an object.

24
Q

What does the range() function do?

A

Generates a sequence of numbers.

25
What does the zip() function do?
Combines multiple iterables into tuples.
26
What does the enumerate() function do?
Returns index and item pairs from an iterable.
27
What does isinstance() check for?
Whether an object is an instance of a specified class/type.