Week 1
Week 1
Rupesh Kumar
Friday, July 26 2024
6-8 PM
2. Humans easily get bored doing a repetitive job. However, computers are masters of
iteration. In programming, we get a control structure that allows a set of instructions
to be executed repeatedly based on a condition. It enables automating repetitive tasks
by iterating through a block of code until a specific condition is met or for a defined
number of times. What is this control structure called?
a. Variable
b. Operator
c. Loop
d. Data Type
Answer: Option c Loop
5. Knowing how to write a piece of code could help us get things done fast. Choose the
areas where we can implement coding.?
a. Physics
b. Mathematics
c. Economics
d. Small Scale Business
Answer: All of the above.
Problem Introduction:
6. The provided image depicts a scene from a presentation featuring The Famous Cat at
Scratch attempting to play football with a Boomerang ball disguised as a volleyball.
The unexpected return of the ball leads to a humorous outcome.
Accompanying is the set of code blocks that achieve what is stated above [Not
necessarily in sequence of execution]. Answer the questions that follow:
The block of code displayed here is meant for the cat, what is the functionality of this code?
a. One
b. Two
c. Three
d. Four
Answer: The Cat makes three complete rotations. Total 4 rotations by 90 degrees
are required for a complete rotation. The outer repeat statement is running the
inside block 3 times and the inner repeat statement is running the rotation
instruction 4 times. So, the cat is being rotated 12 times by 90 degrees.
8. The block of code displayed here makes the cat rotate out of impact from the
boomeranging ball, how many loops are there in total?
a. One
b. Two
c. Three
d. Four
Answer: Option b.
9. The block of code displayed here is meant for the ball, how many loops are there in
total?
a. One
b. Two
c. Three
d. Four
Answer: One loop, Option a.
10. The block of code displayed here is meant for the ball, if the value beside repeat
would have been 1 instead of 2, Select all the statements that explain the situation.
a. The Ball would not have returned to Cat.
b. Removing the loop from the code would have made no difference in the result.
c. The Ball would not have left its original position.
d. The code would throw an error
Answer: Option a. The ball would not have returned to the Cat.
Programming Problems
Write a program to tell the user if they are eligible for voting.
User is elgigible for voting if their age is > 18.
Age
Set Age
If(Age > 18)
Eligible
Else
Not eligible
Write a program to give pass or fail grade to a student based on the obtained
marks. (Passing marks is 40).