Uses minimum symbols
Has only one loop
Produces correct output for all valid inputs
Uses standard variable names
What does the following code do?
from datetime import datetime dt = datetime.strptime("2024-11-22", "%Y-%m-%d") print(dt)
Returns the current date
Converts the string "2024-11-22" to a datetime object
Returns the string "2024-11-22"
Raises a ValueError
What is the output of following?
def add(a, b=5): return a + b print(add(3))
3
5
8
Error
print(input() + input())
print(int(input()) + int(input()))
print(input + input)
print(eval(input))
Declared outside all functions
Declared in loop
Declared using global
Declared inside a function
Debugging is the process of locating and fixing errors
Debugging removes syntax errors only
Debugging is done before testing
Debugging increases algorithm complexity
What will be printed?
x = 10 def f(): x = 20 print(x) f() print(x)
10 10
20 20
20 10
Input/Output operation
Processing step
Decision making
Loop termination
Testing and debugging are identical processes
Testing guarantees error-free programs
Debugging must be completed before testing
Testing reveals defects, while debugging locates and removes them
import math
from math import pi
include math
using math
f = open("test.txt", "r") f.seek(0) print(f.tell())
0
1
File size
Bytecode execution
Syntax analysis
Output generation
Runtime evaluation
for i in range(3): pass print(i)
2
What is printed?
i = 1 while i < 4: print(i, end=" ") i += 1 else: print("Done")
1 2 3
Infinite loop
Done
1 2 3 Done
import math as m
from math import sqrt
load math
a > b
b == 0
while (b != 0)
a == b
Indexing
Slicing
Concatenation
Element assignment
List
Dictionary
Set
Tuple
Tuple of array dimensions
Total elements
Data type
Memory size
What does the following slice return?
s = [0,1,2,3,4,5] print(s[1:5:2])
[1, 3]
[2, 4]
[1, 2, 3, 4]
[0, 2, 4]