🔹 1.
Variables and Data Types (10 Questions)
Q1. Simple Variable Assignment
x = 10
print(x)
1 mark: Correct assignment
1 mark: Correct output
Q2. Multiple Assignments
a, b = 5, 7
print("Sum:", a + b)
1 mark: Multiple assignment
1 mark: Correct output with formatting
Q3. Data Type Identification
x = 7.5
print(type(x))
1 mark: Correct type assignment
1 mark: Correct use of type()
Q4. Swapping Two Variables
a=5
b = 10
a, b = b, a
print(a, b)
1 mark: Correct swap
1 mark: Correct output
Q5. Implicit Type Casting
x=4
y = 2.5
print(x + y)
1 mark: Understanding mixed types
1 mark: Output is float
Q6. String Concatenation
first = "Hello"
second = "World"
print(first + " " + second)
1 mark: Correct use of +
1 mark: Output with space
Q7. Boolean Variable
is_valid = True
print("Is Valid:", is_valid)
1 mark: Boolean assignment
1 mark: Output format
Q8. User Input with Variables
name = input("Enter your name: ")
print("Welcome", name)
1 mark: Correct input
1 mark: Personalized output
Q9. Constants Concept
PI = 3.14159
print("Value of PI:", PI)
1 mark: Naming convention
1 mark: Correct output
Q10. Type Conversion
a = "10"
b = int(a)
print(b * 2)
1 mark: Correct conversion
1 mark: Output is 20
🔹 2. Conditional Statements (10 Questions)
Q1. Simple if statement
x = 10
if x > 5:
print("Greater than 5")
1 mark: if condition
1 mark: Output
Q2. if-else Statement
x = int(input("Enter a number: "))
if x % 2 == 0:
print("Even")
else:
print("Odd")
1 mark: Input
1 mark: if-else logic
1 mark: Correct output
Q3. elif Ladder
marks = int(input("Enter marks: "))
if marks >= 90:
print("A")
elif marks >= 75:
print("B")
else:
print("C")
1 mark: Conditional ladder
1 mark: Input
1 mark: Output category
Q4. Nested if
age = int(input("Enter age: "))
if age >= 18:
if age >= 60:
print("Senior Citizen")
else:
print("Adult")
1 mark: Nested structure
1 mark: Output
Q5. Short Circuiting
a = 10
b=0
if b != 0 and a / b > 1:
print("Valid")
else:
print("Invalid")
1 mark: Logical operator
1 mark: Preventing division by 0
Q6. Check Leap Year
year = int(input("Enter year: "))
if year % 4 == 0 and (year % 100 != 0 or year % 400 == 0):
print("Leap Year")
else:
print("Not Leap Year")
1 mark: Input
1 mark: Logical condition
1 mark: Output
Q7. Ternary Operator
x=5
result = "Even" if x % 2 == 0 else "Odd"
print(result)
1 mark: Correct ternary use
1 mark: Output
Q8. Absolute Value without abs()
x = int(input("Enter number: "))
if x < 0:
x = -x
print("Absolute:", x)
1 mark: Input
1 mark: Conditional conversion
1 mark: Output
Q9. Compare Three Numbers
a, b, c = 3, 7, 5
if a > b and a > c:
print("A is largest")
elif b > c:
print("B is largest")
else:
print("C is largest")
1 mark: Multiple comparisons
1 mark: Correct output
Q10. Password Check
password = input("Enter password: ")
if password == "admin123":
print("Access Granted")
else:
print("Access Denied")
1 mark: Input
1 mark: Condition
1 mark: Output