ANSWER KEY: PYTHON- REVISION WORKSHEET 7TH
7TH COMPUTER REVISION- ANSWER KEY:
1. Name the different types of conditional statements in Python.
ans) If, elif, else
2. Define looping statements in Python. Give any two types of looping statements.
ans) This statement is used to execute a set of instructions multiple times. Eg: while loop, for loop.
3. List the different types of arithmetic operators in Python.
ans)Addition(+) , Subtraction(-) , Multiplication(*) , Division(/).
4. Write a program in Python to print the first 5 multiples of 3 using range function.
ans)
5. Write a program in Python to display whether the number is positive or negative.
ans)
6. Analyse the given code and write the output: n=1 while n<=10: print(n) n=n+1
ans)
7. Differentiate between runtime error and syntax error in Python.
ans)
8. Complete the following python code: num=10 ___if____num%2==0: ____print___(“The number is even number”)
9. Write the output for the following python code: for i in range(5): print(i)
ans) 0
1
2
3
4
10.Mention the use of if..elif..else statement in Python.
ans)This statement is used to handle multiple conditions together. There can be multiple elif blocks , but only one if and else blocks.
11.Compare and contrast between if statement and if-else statement.
ans) if: This statement evaluates whether a statement is true or false and runs only if the statement is true.
If and else: This statement has two blocks. If the expression in the if block is FALSE , it executes the code in the else block.
Comments
Post a Comment