std-8
std-8
std-8
Q1. Rewrite the following code in Python after removing all errors to get the correct output.
Code:
a. number = int(Input("Enter the value of number:")
if number % 2 == 0 and number % 5 == 0:
print("The number is divisible by both 2 and 5.")
elif number % 2 = 0:
print("The number is divisible by 2 but not by 5.")
elif number % 5 == 0
print(The number is divisible by 5 but not by 2.)
els:
print("The number is neither divisible by 2 nor by 5.")
Correct code:
Output:
b.Code:
weather="raining"
if weather="sunny":
print("wear sunblock")
elif weather="snow":
print("Going skiing")
else:
print("None of the above")
Correct code:
Output:
b. Code:
print("Perimeter of a Triangle :", Perimeter)
Area=1/2*(Base* Height)
Side2=int(input("Enter the value of Side2:"))
Base=int(input("Enter the value of Base:"))
Height=int(input("Enter the value of Height:"))
Side1=int(input("Enter the value of Side1:"))
print("Area of a Triangle :", Area)
Side3=int(input("Enter the value of Side3:"))
Perimeter= Side1+Side2+Side3
Correct Code:
Output:
NextGen International Coding and Engineering
(NICE) School & College
Worksheet
Class: STD-VIII
Student’s Name: Subject: Python Programming Language Date: 22.04.24
Correct code:
Q. The following are true/false questions. Write either ‘T’ or ‘F’ in the boxes at the bottom of the page. If there’s
any counter-example, it’s false.
(a) A function must always have a return statement.
(b) Functions in Python can accept multiple arguments, separated by commas when called.
(d) A function created by the user for its own program requirements is called a built-in function.
(f) Default arguments in a function automatically take a default value when no value is specified in the
function call.
(g) When passing a mutable object to a function in Python, the function can modify the object.
(h) A variable, with a global scope can’t be used anywhere in the program.
(i) A variable declared inside the function's body scope is known as a local variable.
(j) In Python, Functions can return only single values using the return statement.
a b c d e f g h i j