Python Programming Language STD-VI
Python Programming Language STD-VI
1
Q. Write a Python program to print the following string in a specific format (see the output).
Program:
x=5
y = 10
x, y = y, x
print("x =", x)
print("y =", y) 2
3
Q. Label the components following program using the given words:
Statement comment variable block keywords
identifiers symbols Indentation Operators Operands
4
International Coding and Engineering
(NICE) School & College
Worksheet
Q. Rewrite the following code in Python after removing all errors in order to get the output.
Code:
• PI=3.14
• radius = float(input("Enter the radius of the circle: ")
• area = PI * (radius ** 2)
• perimeter = 2 * PI * radius
• print("Area of the circle:" area)
• print("Perimeter of the circle:",perimete)
Correct code:
output:
Type of error:___________________________________________________________
Q. Print "I cant't wait until Thanksgiving! I'm going to eat and eat and eat!"
Type of error:_________________________________________________________
Type of error:_________________________________________________________
Type of error:______________________________________________________
2
Q. What kind of errors do the following statements produce?
Type in the following into the SHELL: Is there an error? What is the reason?
print (hello world)
SyntaxError: invalid syntax. Perhaps you forgot a comma?
02
03
03
03
04
3
Q. Write down the correct answers:
1. Who created Python in the late 1980s?
a) Guido von b) Guido van Rossum c) Monty Python d) Tim Burnus
Ans:
2. The primary prompt in Python is__________.
a) >>> b) >> c) >= d)<=
Ans:
3. Python is processed at run time by a __________.
a) Compiler b) Assembler c) Interpreter d) None
Ans:
4. __________ is the grammar of a programming language.
a) Both c,d b) Syntax Error c) Virus d) Logical Error
Ans:
5. Syntax Error is also known as _______________.
a) Worm b) Virus c) Bug d) Debug
Ans:
4
NextGen International Coding and Engineering
(NICE) School & College
Worksheet
1
Instruction: Write down answers of flowing questions in copy
2
Q. Write a Python program with output to perform given string operations on str1= “Hello” and str2=
“Python”
Operations:
1. Concatenation Operation
2. Replication Operation
3. in Operation
4. not in Operation
5. Comparison Operation
6. Slicing Operation
3
Q. Match the code with the correct output.
Code Output
print((pizza[0])) w
print(pizza[0:5]) a
print (pizza[0:2]) Hawai
print(pizza) H
print(pizza[6]) aiian
print(pizza[2]) pizza[6]
4
a. Write Code for changing int into a string
x= 12
print(x)
Changed code:
Q. In the space below, write a program with output to ask the user for their full name. It should output: a. “The whole
name is:” b. “The first character is:” c. “The first 5 characters are:” d. “The fourth character is:”
5
NextGen International Coding and Engineering
(NICE) School & College
Worksheet
False type(false)
15 type(15)
35.6 type(35.6)
-999 type(-999)
"15" type("15")
"False" type("False")
True type(True)
0.001 type(0.001)
i. num_1: ____________
i. Line___________________________