[go: up one dir, main page]

0% found this document useful (0 votes)
65 views4 pages

Intro To Python Class 9

this is about computer science of kips publishers question and answer

Uploaded by

puja srivastava
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)
65 views4 pages

Intro To Python Class 9

this is about computer science of kips publishers question and answer

Uploaded by

puja srivastava
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/ 4

A.

Short Answer Type Questions

1. What is an algorithm?
An algorithm is a step-by-step procedure or set of rules to solve a problem or perform a task in
a finite amount of time.

2. What is a flowchart?
A flowchart is a pictorial or graphical representation of an algorithm using standard symbols to
show the flow of control in programs or processes.

3. List all the standard graphics for making a flowchart.


Standard flowchart symbols include:

• Oval (Terminator) for Start/Stop

• Parallelogram for Input/Output

• Rectangle for Process/Instruction

• Diamond for Decision

• Arrow for Flowline or Direction

4. Define membership operators.


Membership operators in Python are used to test whether a value or variable is found in a
sequence (such as a string, list, tuple, etc.). The operators are in and not in.

5. What is an infinite loop?


An infinite loop is a loop that runs endlessly because the terminating condition is never
satisfied or not present.

6. Write the difference between 'else' and 'elif' statements.

• elif (else if) allows checking multiple conditions sequentially after an initial if.

• else is the final block that executes if none of the preceding if or elif conditions hold true.

7. What are nested loops?


Nested loops are loops placed inside another loop. The inner loop executes completely every
time the outer loop runs once.

8. Write the syntax for a nested 'if-else'.


B. Long Answer Type Questions

1. Write an algorithm to display how a traffic signal works.


Algorithm:

• Start

• Initialize signal as Red

• Display "Red Light ON" for 30 seconds

• Change signal to Green

• Display "Green Light ON" for 30 seconds

• Change signal to Yellow

• Display "Yellow Light ON" for 5 seconds

• Repeat the cycle

• Stop

2. Explain 'if-else' statement with a flowchart.


The 'if-else' statement tests a condition; if true, executes one block of code, else executes
another.
Flowchart elements:

• Decision diamond for condition check

• Two branches (Yes/No) leading to respective code blocks

• Merge back to continue flow

3. What is the difference between a division operator and a floor division operator?

4. Describe the use of the input() and print function().

The input() function pauses program execution to take input from the user as a string. It can
display a prompt message to guide the user. For example, name = input("Enter your name: ") takes
the user's name.
The print() function outputs data to the console. It can print strings, variables, or multiple items
separated by commas. It automatically appends a newline after printing. For example,
print("Hello", name) displays a greeting with the entered name. The print() function also supports
special parameters like sep to change separator between multiple items and end to control what
is printed at the line end.

5. What is the difference between 'for' loop and 'while' loop? Explain with the help of a
flowchart.

• A for loop iterates over a sequence or a defined range a specific number of times. It is mostly
used when the number of iterations is known upfront.

• A while loop continues to run as long as a condition remains true, making it suitable for
unspecified iterations like waiting for user input or until a certain event occurs.

6. What are Python nested-if statements? Explain with an example.

Nested-if statements allow testing multiple conditions inside another condition to refine decision-
making. For example:
7. Difference between tuple and list data types:

Tuples are immutable, meaning their values cannot be changed once created. They use
parentheses ( ).

Lists are mutable and can be modified later. They use square brackets [ ].

Tuples can be used for fixed data storage (like coordinates), whereas lists are preferred where the
data changes dynamically (like item collections). Tuples may also have slightly better performance.

8. What is typecasting? Explain its types.

Typecasting converts a variable from one data type to another.

• Implicit typecasting is automatic conversion by Python when mixing data types without
programmer intervention, like converting an integer to float in arithmetic.

• Explicit typecasting is manual conversion using functions like int(), float(), or str(). For
example, int("123") converts the string "123" to integer 123.

9. Write a program to find numbers that are divisible by 7 and multiples of 5 between

1200 and 2200.

10. Write a program to input the monthly income of an employee between 40 and 60 years old
and calculate the annual income tax on the basis of the following:

Tax Slab Rate


3 lakhs NIL
3 lakhs to 5 lakhs 5.00%
5 lakhs to 10 lakhs 20.00%
10 lakhs and more 30.00%

You might also like