[Sequential Flow] Find the output with dry run: x = 10 y = 4 z = x - y w = z + 6 print("Result:", w)
Every question in this chapter, answered and explained — step-by-step solutions drawn live from the chapter library across 5 question sections.
[Sequential Flow] Find the output with dry run: x = 10 y = 4 z = x - y w = z + 6 print("Result:", w)
[Sequential Flow] Find the output with dry run: c = 25 f = (c * 9/5) + 32 print("Fahrenheit =", f)
[Sequential Flow] Find the output with dry run: p = 1000 r = 5 t = 2 si = (p * r * t) / 100 print("Si =", si)
[Conditional Structure] Find the output with dry run: n = 12 if n > 0: print("Positive") print("End")
[Conditional Structure] Find the output with dry run: t = 32 if t >= 40: print("Hot") elif t >= 25: print("Warm") else: print("Cold")
[Conditional Structure] Find the output with dry run: y = 2024 if y % 400 == 0 or (y % 4 == 0 and y % 100 != 0): print("Leap Year") else: print("Not Leap Year")
[Loop Structure] Find the output with dry run: for i in range(1, 6): print(3, "x", i, "=", 3 * i)
[Loop Structure] Find the output with dry run: i = 2 while i <= 10: print(i) i = i + 2
[Loop Structure] Find the output with dry run: w = "PYTHON" c = 0 for x in w: c = c + 1 print("Total =", c)
[Loop Structure] Find the output with dry run: n = [2, 3, 4] p = 1 for x in n: p = p * x print("Product =", p)
[Nested Loop] Find the output with dry run: i = 5 while i >= 1: j = i while j >= 1: print(j, end=" ") j = j - 1 print() i = i - 1
[Nested Loop] Find the output with dry run: for i in range(1, 4): for j in range(1, 4): print(i*j, end=" ") print()
[User-Defined Function] Find the output: def cube(n): return n**3 a = 2 b = cube(a) print(b)
[User-Defined Function] Find the output: def check_even(n): if n % 2 == 0: return "Even" else: return "Odd" print(check_even(9))
[User-Defined Function] Find the output: def grade(marks): if marks >= 80: return "A" elif marks >= 60: return "B" else: return "C" print(grade(72))
[User-Defined Function] Find the output: def sum_digits(n): s = 0 while n > 0: d = n % 10 s = s + d n = n // 10 return s num = 253 print(sum_digits(num))
[User-Defined Function] Find the output: def is_armstrong(n): s = 0 t = n while t > 0: d = t % 10 s += d ** 3 t //= 10 return s == n num = 153 print(is_armstrong(num))
[User-Defined Function] Find the output: def triangle_type(a, b, c): if a == b and b == c: return "Equilateral Triangle" elif a == b or b == c or a == c: return "Isosceles Triangle" else: return "Scalene Triangle" x = 5 y = 5 z = 5 r = triangle_type(x, y, z) print(r)
[User-Defined Function] Find the output: def right_triangle(a, b, c): if a*a + b*b == c*c: return "The triangle is Right-angled." else: return "The triangle is Not right-angled." x = 3 y = 4 z = 5 r = right_triangle(x, y, z) print(r)
Write a Python program to input two numbers and display their sum, difference, product, quotient, remainder, and power (the first number raised to the second).
Write a program to display the multiplication table of a number entered by the user.
Create a program that takes numbers from the user and stores them in a list. Separate even and odd numbers into two different lists, then print both lists.
Create a Python program using a function to convert temperature from Celsius to Fahrenheit. Use the formula (Celsius x 9/5) + 32.
Write a Python program with a function to calculate the cube of a number.
Create a Python program using a function to convert the total number of days into years, weeks, and remaining days (1 year = 365 days, 1 week = 7 days).
Write a function that defines a local variable message with the value "Hello, Students!" and prints it inside the function.
Create a program with a global variable count = 0. Write a function increment() that adds 1 to count and displays it using the global keyword. Call the function twice.
Write a function using a positional parameter to calculate the area of a rectangle, given its length and breadth.
Write a function to calculate the area of a circle with a default value for pi, so that the caller may optionally supply a more precise value.
Write a function to display a student's name, roll number, and grade using keyword arguments.
Write a function using variable-length parameters (*args) to find the largest number from any number of numbers passed to it.
Write a function that takes a number as an argument and prints its square root.
Write a function that takes a dictionary containing a book's title and author, then prints them.
Write a function that takes two numbers and returns their sum.
Write a function that takes the base and height of a triangle and returns its area.
Create a module calculator.py with two functions, square(num) and cube(num). Show how another program would import this module and display the square and cube of a number.
Create a package geometry with a module area.py containing functions rectangle_area(l, b) and circle_area(r). Show how a program would use these functions.
Define a function in Python. Write any two advantages of using functions.
Differentiate between local scope and global scope.
Write a program using continue to print only the odd numbers from 1 to 7.
Find the error in the following program and correct it: def is_prime(n): if n < 2: return False for i in range(2, n+1): if n % i == 0: return False return True print(is_prime(17))
Write a function using variable-length parameters (*args) that calculates the average of any number of values passed to it.
What will be the output of the following program? text = "SEE Exam" print(text.lower()) print(text.upper()) print(len(text))
Write a function get_squares(n) that returns a list containing the squares of the first n natural numbers.
What will be the output of the following nested loop with a break statement? for i in range(1, 4): for j in range(1, 4): if j == 2: break print(i, j)
Write any four differences between a module and a package in Python.
Write a function that takes a Boolean value as an argument and prints "Eligible" if True and "Not Eligible" if False.
What is a Python library?
Which of the following is used to import the entire math library in Python?
What does the math.sqrt() function do?
Which function from the random library is used to generate a random integer between two values?
What is the correct way to import only the sqrt function from the math library?
What is the use of the pandas library in Python?
Which of the following libraries is used for drawing shapes like squares and circles in Python?
What is the use of matplotlib in Python?
Which command is used to install external libraries in Python?
In which of the following cases would you use random.choice()?
What is the primary purpose of the Turtle library in Python?
Which Turtle function moves the turtle forward by a specified number of units?
Which function would you use to lift the pen so the turtle moves without drawing?
What does the following code do? t.fillcolor("blue"); t.begin_fill(); # draw a square; t.end_fill()
Which Turtle function sets the shape of the turtle cursor?
What will this code draw? for i in range(3): t.forward(100); t.right(120)
Which of the following is NOT a valid turtle function?
Which function in the Turtle library is used to change both the pen and fill color together?
What will this code do? t.penup(); t.forward(100); t.pendown(); t.circle(50)
Which function stops filling the shape with color in Turtle graphics?