SsyMZX1xgs
SsyMZX1xgs
Answer: b. RAM
Identify the invalid literal from the following.
python
Copy code
i = 10
s=0
while i > 5:
s=s+i
i=i-1
print(s)
Answer: The loop runs for i = 10 to i = 6, so the sum s=10+9+8+7+6=40s = 10 + 9 + 8 + 7 + 6 = 40s=10+9+8+7+6=40. The output is 40.
Correct statement for storing value 3.5 in variable n:
Answer: b. n = 3.5
Which of the following is not a valid identifier?
Answer: Decomposition
____________ is a sequence of steps that solves a problem by working on some input data and producing a desired output.
Answer: Algorithm
____________ statement represents a group of statements executed as a unit.
Answer: Block
Assertion (A): In python program variables a and A have different significance. Reason (R): Python is case insensitive language.
Answer: 1, 2, 4, 8
Correct the following code:
python
Copy code
a = input("Enter value: ")
b = 10
result = int(a) / b
print("The answer is", result)
Draw flow chart to check and print the greatest number among three numbers:
The flowchart would involve checking conditions A>BA > BA>B, B>CB > CB>C, etc., using decision boxes.
Section C (3 marks each):
What is a Literal? Define two types with examples.
Literals are constant values in Python. Two types:String Literal: Example: "Hello"
Integer Literal: Example: 100
Evaluate the following expressions: a. 45+2 10−30//4/245+ 2 * 10 - 30 // 4 / 245+2 10−30//4/2
Answer: 61.25
b. 7+3 2%4−97 + 3**2 \% 4 - 97+3 2%4−9
Answer: -1
c. 6>86 > 86>8 and 9>29 > 29>2 or 2<92 < 92<9 and 3>23 > 23>2
Answer: True
Predict the output of the following code:
python
Copy code
s, f = 0, 0
for j in range(5):
s=s+j
f=f*j
print(2 ** j, end="-")
print(s, f)
Answer: 1-2-4-8-16-10 0
Program to print the factors of a number:
python
Copy code
num = int(input("Enter a number: "))
for i in range(1, num + 1):
if num % i == 0:
print(i)
Program to check if a number is an Armstrong number:
python
Copy code
num = int(input("Enter a number: "))
sum = 0
temp = num
while temp > 0:
digit = temp % 10
sum += digit ** 3
temp //= 10
if num == sum:
print(num, "is an Armstrong number")
else:
print(num, "is not an Armstrong number")
Answer: 1
c. print(7 & 3)
Answer: 3
d. print(5 != 5)
Answer: False
e. print(print("abc"))