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
Error
What is the output?
f = open("test.txt", "w") f.write("Python") print(f.tell()) f.close()
5
6
7
0
File size
Current file pointer position
Number of lines
Number of characters remaining
r
w
a
r+
What will be the output?
f = open("test.txt", "w") f.write("Python") f.seek(0) print(f.read())
Python
Empty String
UnsupportedOperation Error
None
import math as m print(m.factorial(4))
4
16
24
import random print(random.randint(1,1))
1
Random number
import math print(math.ceil(4.2))
4.2
import math print(math.sqrt(-1))
ValueError
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
30
25
False
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