Python Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

What are diffierent type of datatypes in python?

A

integer, float, string, boolean, list, dictionary, sets, tuples

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

How to calculate mode and power in python?

A

%, **

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

Is it possible to assign different data types to same variable?

A

yes

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

How to reverse string?

A
s = hardik
s_reversed = s[::-1]
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

How to get every alternate character?

A
s = hardik
s_alternate = s[::2]
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Indexes in string? are they mutable?

A

yes

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

How to split a sentence?

A

Split()

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

What are different methods for a string?

A

None

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

explain what is .format and f’ format? What is the difference?

A

None

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

Can we store different datatypes in list? How to add a value to a list

A

None

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

Explain indexing in list

A

None

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

List at least five methods for list

A

None

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

How do I index a nested list? For example if I want to grab 2 from [1,1,[1,2]]?

A

None

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

Define Dictionaries? Write one dictionary

A

None

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

How to assign values in dictionary

A

None

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

List key mehtonds for dictionary

A

None

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

What is set in python and how to create a sets?

A

None

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

Explain use of boolean datatypes

A

None

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

How to create file inside Jupyter notebook?

A

None

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

How to read a file? What happens if you read again?

A

None

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

What is the use of myfile.seek() method?

A

None

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

Why to use readlines() method?

A

None

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

In windows why there are to back slash?

A

None

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

What is the use of myfile.close()? How to avoid it? (with open)

A

None

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

What are different modes for opening file?

A

None

26
Q

List all comparison operators

A

None

27
Q

Write example if statement

A

None

28
Q

Write example for loop

A

None

29
Q

Write example while?

A

None

30
Q

When to use for loop vs While loop?

A

None

31
Q

What is unpacking? Which function can be used?

A

None

32
Q

Explain Enumerate

A

None

33
Q

Explain Zip

A

None

34
Q

Explain Range

A

None

35
Q

what happens if list length is uneven

A

None

36
Q

What is the use of β€œIN” operator?

A

None

37
Q

How to input some values? What is data type of input value?

A

None

38
Q

Random library - shuffle, randint functions

A

None

39
Q

Write sqaure of in a range?

A

None

40
Q

Write list comprehension to find prime numbers

A

None

41
Q

Write if else in list comprehension

A

None

42
Q

Assign default value to a function.

A

None

43
Q

How to pass unlimted arguments as list and dictionary?

A

None

44
Q

Nested statement and scope - LEGB

A

None

45
Q

What is global keyword? How is it used?

A

None

46
Q

explain - def __init__ method in class

A

None

47
Q

What is self method,? why is it passed to class

A

None

48
Q

Explain inheritance? Give example of it.

A
class dog(Animal):
		def \_\_init\_\_(self):
			Animal. \_\_init\_\_(self)
49
Q

Explain a scenario where you would use inheritance?

A

None

50
Q

Is it possible to pass multiple classes?

A

None

51
Q

polymorphism - Explain a scenairo where you would use it..

A

exaple of animal classes .. cat, dog making different sound

52
Q

Explain abstract class

A

None

53
Q

Explain special/dunder/magic methods in class.. why is it used

A
def \_\_str\_\_():
def\_\_len\_\_() etc
54
Q

What is use of pypi pakcage

A

None

55
Q

how to install new python package?

A

None

56
Q

List the keywords used for handling exceptions

A

try, except, else, finally

57
Q

how to catch all other exceptions

A

None

58
Q

List atleast five builtin exceptions

A

None

59
Q

What are decorators in python? Explain its use.

A

None

60
Q

Explain use of generators. Create one Generator

A

None