0% found this document useful (0 votes)
4 views2 pages

Programs

The document contains a series of programming questions focused on writing code and tracing outputs in Python. It includes tasks such as determining outputs of given code snippets, writing programs for specific functionalities, and tracing the execution of loops and conditions. The questions cover various programming concepts including loops, conditionals, and user input.

Uploaded by

histreeedite
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views2 pages

Programs

The document contains a series of programming questions focused on writing code and tracing outputs in Python. It includes tasks such as determining outputs of given code snippets, writing programs for specific functionalities, and tracing the execution of loops and conditions. The questions cover various programming concepts including loops, conditionals, and user input.

Uploaded by

histreeedite
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

All questions are program-writing or output-tracing!

Q1.
What will be the output of the following code?

x = 15
y=4
print(x // y, x % y)
print(x > y and y > 2)

Q2.
What will be the output?

for i in range(2, 12, 3):


print(i, end=" ")

Q3.
What will be the output of the following code?

x = 10
y=3
print(x ** y)
print(x is not y)
print(type(x + 0.5))

Q4.
Write a Python program to check whether a number entered by the user is divisible by both 3
and 5, only one of them, or neither.

Q5.
Write a Python program to print the following pattern:

1
12
123
1234

Q6.
Trace the output of this code:
i=1
while i <= 20:
if i % 6 == 0:
break
if i % 2 != 0:
print(i, end=" ")
i += 1

Q7.
Write a Python program to find the sum of all even numbers between 1 and n, where n is
entered by the user.

Q8.
Write a Python program to calculate the sum of the series:
S = 1² + 2² + 3² + … + n²
where n is entered by the user.

Q9.
Write a Python program to accept three numbers from the user and print them in descending
order using if-elif-else (without sort()).

Q10.
Write a Python program to find the factorial of a positive integer using a while loop. The program
should print an appropriate message if the user enters a negative number or zero.

You might also like