{ "@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 5 Flashcards

(20 cards)

1
Q

How do you read a CSV file in pandas?

A

pd.read_csv(‘filename.csv’)

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

How do you write a DataFrame to a CSV file?

A

df.to_csv(‘filename.csv’, index=False)

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

How do you read a JSON file with pandas?

A

pd.read_json(‘filename.json’)

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

How do you read an Excel file with pandas?

A

pd.read_excel(‘filename.xlsx’)

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

How do you write a DataFrame to an Excel file?

A

df.to_excel(‘filename.xlsx’, index=False)

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

How do you open a file in Python?

A

with open(‘file.txt’, ‘r’) as f:

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

What does ‘r’ mode mean in open()?

A

Read-only mode.

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

What does ‘w’ mode mean in open()?

A

Write mode; overwrites the file.

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

How do you read all lines from a file?

A

f.readlines()

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

How do you write to a file?

A

f.write(‘some text’)

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

What is an API?

A

An Application Programming Interface that allows software to communicate with other systems.

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

What is a REST API?

A

A type of web API based on representational state transfer principles.

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

How do you make a GET request in Python?

A

Using requests.get(‘url’)

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

How do you pass query parameters in a GET request?

A

requests.get(‘url’, params={‘key’: ‘value’})

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

How do you read a JSON response from an API?

A

response.json()

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

How do you convert a string to lowercase?

A

string.lower()

17
Q

How do you split a string by spaces?

A

string.split()

18
Q

How do you join a list of strings?

A

’ ‘.join(list_of_strings)

19
Q

How do you replace part of a string?

A

string.replace(‘old’, ‘new’)

20
Q

How do you strip whitespace from a string?

A

string.strip()