Python Flashcards
What are diffierent type of datatypes in python?
integer, float, string, boolean, list, dictionary, sets, tuples
How to calculate mode and power in python?
%, **
Is it possible to assign different data types to same variable?
yes
How to reverse string?
s = hardik s_reversed = s[::-1]
How to get every alternate character?
s = hardik s_alternate = s[::2]
Indexes in string? are they mutable?
yes
How to split a sentence?
Split()
What are different methods for a string?
None
explain what is .format and fβ format? What is the difference?
None
Can we store different datatypes in list? How to add a value to a list
None
Explain indexing in list
None
List at least five methods for list
None
How do I index a nested list? For example if I want to grab 2 from [1,1,[1,2]]?
None
Define Dictionaries? Write one dictionary
None
How to assign values in dictionary
None
List key mehtonds for dictionary
None
What is set in python and how to create a sets?
None
Explain use of boolean datatypes
None
How to create file inside Jupyter notebook?
None
How to read a file? What happens if you read again?
None
What is the use of myfile.seek() method?
None
Why to use readlines() method?
None
In windows why there are to back slash?
None
What is the use of myfile.close()? How to avoid it? (with open)
None
What are different modes for opening file?
None
List all comparison operators
None
Write example if statement
None
Write example for loop
None
Write example while?
None
When to use for loop vs While loop?
None
What is unpacking? Which function can be used?
None
Explain Enumerate
None
Explain Zip
None
Explain Range
None
what happens if list length is uneven
None
What is the use of βINβ operator?
None
How to input some values? What is data type of input value?
None
Random library - shuffle, randint functions
None
Write sqaure of in a range?
None
Write list comprehension to find prime numbers
None
Write if else in list comprehension
None
Assign default value to a function.
None
How to pass unlimted arguments as list and dictionary?
None
Nested statement and scope - LEGB
None
What is global keyword? How is it used?
None
explain - def __init__ method in class
None
What is self method,? why is it passed to class
None
Explain inheritance? Give example of it.
class dog(Animal): def \_\_init\_\_(self): Animal. \_\_init\_\_(self)
Explain a scenario where you would use inheritance?
None
Is it possible to pass multiple classes?
None
polymorphism - Explain a scenairo where you would use it..
exaple of animal classes .. cat, dog making different sound
Explain abstract class
None
Explain special/dunder/magic methods in class.. why is it used
def \_\_str\_\_(): def\_\_len\_\_() etc
What is use of pypi pakcage
None
how to install new python package?
None
List the keywords used for handling exceptions
try, except, else, finally
how to catch all other exceptions
None
List atleast five builtin exceptions
None
What are decorators in python? Explain its use.
None
Explain use of generators. Create one Generator
None