0% found this document useful (0 votes)
7 views8 pages

SsyMZX1xgs

The document contains a series of questions and answers related to computer science concepts, including memory types, programming syntax, logical circuits, and algorithms. It covers topics such as literals, data types, operators, and flowcharts, along with code snippets and their expected outputs. Additionally, it includes exercises on converting number systems, programming tasks, and definitions of key terms in programming.

Uploaded by

chirantanhari
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)
7 views8 pages

SsyMZX1xgs

The document contains a series of questions and answers related to computer science concepts, including memory types, programming syntax, logical circuits, and algorithms. It covers topics such as literals, data types, operators, and flowcharts, along with code snippets and their expected outputs. Additionally, it includes exercises on converting number systems, programming tasks, and definitions of key terms in programming.

Uploaded by

chirantanhari
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
You are on page 1/ 8

Let's go through and solve the questions from the provided PDF.

I'll address each section:

Section A (1 mark each):


Which of the following is an example of Primary memory?

Answer: b. RAM
Identify the invalid literal from the following.

Answer: c. 0x234 (Hexadecimal numbers can't have letters beyond F)


The system software which converts the source code to machine language is known as ________.

Answer: c. Language Processor


Which of the following is not a valid hexadecimal number?

Answer: c. 2AL (Hexadecimal uses digits 0-9 and letters A-F)


The output of two-input NOR gate is high when:

Answer: a. both inputs are low


IDLE stands for ____________.

Answer: Integrated Development and Learning Environment


Predict the output:

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: a. 2BOOK (Identifiers cannot start with a number)


Which of the following gate is a combination of two gates?

Answer: d. NOR (combination of NOT and OR)


Identify the invalid octal number from the following:

Answer: c. 284 (Octal numbers use digits 0-7)


Which of the following is not a valid operator?

Answer: a. ++ (Python does not support the increment operator ++)


Identify the incorrect statement from the following:
Answer: b. X = 0234 (In Python, octal literals are written as 0o234)
The process of breaking down a complex problem into smaller sub-processes is known as ____________.

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: c. A is True but R is False


Assertion (A): Python does not support explicit type casting. Reason (R): Data type is not a part of variable declaration.

Answer: d. A is false but R is True

Section B (2 marks each):


Convert the following numbers accordingly: a. (110011)2=(?)10(110011)_2 = (?)_{10}(110011)2=(?)10
Answer: 51
b. (345)8=(?)2(345)_8 = (?)_2(345)8=(?)2

Answer: 011100101 (Convert 345 in octal to binary)


Logical Circuit for the Expression: (A.B)+(B.C).(B+C)(A.B) + (B.C).(B + C)(A.B)+(B.C).(B+C):
Draw the circuit for the given Boolean expression using AND, OR, and NOT gates.
Two differences between RAM and ROM:
RAM is volatile, while ROM is non-volatile.
RAM is used for temporary data storage, while ROM stores permanent instructions.
Print statement to produce the output:
css
Copy code
I love
Narayana School
West Bengal

Answer: print("I love\nNarayana School\nWest Bengal")


Output for the code:
python
Copy code
for i in range(1,25):
if 24 % i == 0:
if i % 3 == 0:
continue
print(i)

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")

Section D (5 marks each):


What is Token? Define all types with examples.
Tokens are the smallest units in a program. Types:Keywords: if, while
Identifiers: x, my_function
Literals: "hello", 100
Operators: +, -
Punctuators: (), {}
Pattern programs (write programs to generate the given patterns).
Predict the output: a. print(bool(30))
Answer: True
b. print(6 >> 2)

Answer: 1
c. print(7 & 3)
Answer: 3
d. print(5 != 5)

Answer: False
e. print(print("abc"))

Answer: abc followed by None

Section E (4 marks each):


Complete the code for Heron’s formula:
python
Copy code
import math
a = float(input("Enter side a: "))
b = float(input("Enter side b: "))
c = float(input("Enter side c: "))
s = (a + b + c) / 2
area = math.sqrt(s * (s - a) * (s - b) * (s - c))
print("Area of triangle = ", area)

Program to print 20 prime numbers:


python
Copy code
count = 0
num = 2
while count < 20:
for i in range(2, num):
if num % i == 0:
break
else:
print(num)
count += 1
num += 1

You might also like