Arrow
Oval
Rectangle
Diamond
Parallelogram
Circle
Sequence
Branch
Loop
Condition
Sequential processing
Parallel processing
Decision processing
Iterative processing
Prime numbers
Fibonacci sequence
Even numbers
Odd numbers
1 and itself
1 and 2
All numbers
2 and itself
Program logic
Database
Network
Hardware design
Algorithm
Diagram
Machine code
Flowchart
Compiling code
Removing errors
Designing hardware
Writing code
int
string
complex
float
str
set
Brackets
Quotes
Braces
Parentheses
:=
=
==
!=
%
//
/
**
*
<>
=!
not
or
and
xor
~
|
&
^
skip
continue
break
pass
assert
for
while
if
exit
range()
input()
len()
list()
Tuple
Integer
String
List
Dictionary
Set
{}
[]
()
Appending
Concatenation
Deleting
Slicing
What is the output of following code
x = [1, 2, 3] print(x[1:10])
Error
[2, 3]
[1, 2, 3]
a = "Python" print(a[-4:-1])
tho
yth
hon
thoN
x = [10, 20, 30] print(x * 0)
[0, 0, 0]
[ ]
0
x = "HELLO" print(x[1:-1])
ELL
ELLO
HELL
LL
d = {1:"A", 2:"B", 1:"C"} print(d)
{1:'A',2:'B'}
{1:'C',2:'B'}
{1:'A',1:'C',2:'B'}
d = {} d[1] = "Python" d[2] = "Java" print(len(d))
1
2
a = [1,2,3] del a[1] print(a)
[1,2,3]
[1,3]
[2,3]
a = [5,2,3] print(a[5:])
None
5
Local, Enclosing, Graphical, Built-in
Local, External, Global, Binary
List, Entry, Global, Block
Local, Enclosing, Global, Built-in
static
global
public
extern
A package manager
A loop structure
A file containing Python code
A variable type
Local variable gets priority
Global variable gets priority
Error occurs
Both are merged
create()
tuple()
array()
size
dtype
ndim
shape
space()
arange()
linspace()
print( 5 in 515)
True
False
TypeError
ValueError
a=[2,3,4,5] a.insert(3,1) print(a)
[3,2,3,4,5]
[2, 3, 4, 1, 5]
[2, 3,1, 4, 5]
[2, 3,3, 4, 5]
a=[1,2,3] a[::-1] print(a)
[3,2,1]
[2,1,3]
[3,1,2]
seek()
read()
close()
tell()
move()
shift()
w
rb
rt
r
Data is appended
Old content is erased
Nothing happens
random
sys
math
os
End Of Folder
Exit Open File
End Of File
Error On File
readlines()
readline()
readlist()
readall()
What will be the output?
a = [1, 2, 3] b = a b.append(4) print(a)
[1, 2, 3, 4]
[4]
What will be printed?
a = [1, 2, 3] print(a * 2)
[2, 4, 6]
[1, 2, 3, 1, 2, 3]
[1, 4, 9]
What will be the result?
a = [1, 2, 3] print(a[1:])
[1]
[1, 2]
a = [1, 2, 3] a.insert(1, 10) print(a)
[1, 10, 2, 3]
[10, 1, 2, 3]
[1, 2, 10, 3]
a = [[1, 2], [3, 4]] print(a[1][0])
3
4
What is the output?
a = [1, 2, 3] a.remove(2) print(a)
[1, 3]
a = [1, 2, 3] print(a + [4, 5])
[1, 2, 3, 4, 5]
[5, 7, 8]
[4, 5, 1, 2, 3]
t = (5) print(type(t))
<class 'tuple'>
<class 'int'>
<class 'list'>
(10)
[10]
(10,)
{10}
t = (1, 2, 3) t[1] = 5 print(t)
(1, 5, 3)
(1, 2, 3)
a, b, c = (10, 20, 30) print(b)
10
20
30
d = {"a": 1, "b": 2} print(2 in d)
KeyError
a={'a':4,'b':6,'a':7} print(a)
{'a': 5, 'b': 6,'a': 7 }
{'a': 7, 'b': 6}
{'a': 5, 'b': 6 }
Key Error
dict1={'a':[3,6,8]} print(len(dict1))
import numpy as np a = np.array([[1,2],[3,4]]) print(a.shape)
(4,)
(2,2)
(2,1)
How many values are generated?
import numpy as np print(np.linspace(0, 10, 6))
6
11
import numpy as np a = np.array([1,2,3]) b = np.array([4,5,6]) print(a+b)
[5 7 9]
[1 2 3 4 5 6]
21
import numpy as npa a=np.array([1,2,3]) print(a*2)
[2 4 6]
[1 2 3 1 2 3]
[3 4 5]
What happens if the file does not exist?
f = open("abc.txt", "r")
New file is created
FileNotFoundError
Returns None
Opens empty file
What will be written to the file?
f = open("test.txt", "w") f.write("ABC") f.write("DEF") f.close()
ABC
DEF
ABCDEF
f = open("test.txt", "w") f.write("Python") print(f.tell()) f.close()
7
File size
Current file pointer position
Number of lines
Number of characters remaining
a
r+
f = open("test.txt", "w") f.write("Python") f.seek(0) print(f.read())
Python
Empty String
UnsupportedOperation Error
import math as m print(m.factorial(4))
16
24
import random print(random.randint(1,1))
Random number
import math print(math.ceil(4.2))
4.2
import math print(math.sqrt(-1))
NaN
def fun(a,b=2,c=3): print(a,b,c) fun(1,c=10)
1 2 10
1 10 3
1 3 10
def fun(a,b=5,c=10): print(a+b+c) fun(2,c=20)
27
17
22
def fun(a, b=5): print(a+b) fun(10, 20)
15
25
Recursive Function
Lambda Function
Built-in Function
Generator Function
lambda x => x+1
lambda(x): x+1
lambda x: x+1
def lambda(x): x+1
Can contain multiple statements
Can have only one expression
Must use return statement
Cannot take arguments
Calling one function from another function
Calling a function repeatedly from itself
Using nested loops
Using lambda functions
Required Argument
Keyword Argument
Default Argument
Decimal Argument
Positional
Keyword
Default
Variable
#
Increases code duplication
Reduces code reusability
Promotes code reusability and modularity
Makes program slower
Anonymous Function
x = 10 def fun(): global x x = 20 fun() print(x)
Local Variable
Static Variable
Global Variable
Instance Variable
Global Scope
Built-in Scope
Local Scope
Module Scope