0% found this document useful (0 votes)
30 views

Python Programming Language STD-VI

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views

Python Programming Language STD-VI

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 18

NextGen International Coding and Engineering

(NICE) School & College


Worksheet

Student’s Name: Subject: Python Programming Language Date:


Teacher’s Name: Jahanara Taznina Orin Roll: Class: STD VI

Q. Match the correct statement in order to make the code error-free.

1
Q. Write a Python program to print the following string in a specific format (see the output).

Program:

Q. write down the output of the given codes:

x=str(input("Enter your name:")) Enter your name:ABC


print("Your Name:",x) Your Name: ABC

x=int(input("Enter your value of x:"))


y=int(input("Enter your value of y:"))
print("Addition Result:",x+y)

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

Student’s Name: Subject: Python Programming Language Date:


Teacher’s Name: Jahanara Taznina Orin Roll: Class: STD VI

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:

Q. totalAge = age1 + age2 + age3 + age4


1
numAge = 4
aveAge = totalAge/numAge
print(aveAge)

Type of error:___________________________________________________________

Q. Print "I cant't wait until Thanksgiving! I'm going to eat and eat and eat!"

Type of error:_________________________________________________________

Q. Input "Please enter your groups golf scores:"


print "First score ==>", score1
print "Second score ==>", score2
print "Third score ==>", score3
print "Fourth score ==>", score4
TotalScore = score1 + score2 + score3 + score4

Type of error:_________________________________________________________

Q. PRINT I like CSC001 so much, I'm going to major in C.S.

Type of error:______________________________________________________

Q. print ("First score ==>", score1)


print ("Second score ==>", score2)
score1=18
score2=89
TotalScore = score1 + score2
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?

print ”hello world”

print (“hello world)

Print (“hello world”)

print (“hello world”

print (“Yo world, how is it going”)


No Error

print (“Hello World”);

Q. Look at each program and identify the errors in each.


Classify them as either syntax or logic errors. Make sure you can explain your
answer and provide the corrected code.
Example
This program should divide the first number by the second
01 number1 = input(“Please enter a number”)
02 number2 = input (“Please enter another number)
03 Sum = number 1 - numBer2
04 print (Summ)

Line Error Explanation Corrected code (if needed)

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

Student’s Name: Subject: Python Programming Language Date:


Teacher’s Name: Jahanara Taznina Orin Roll: Class: STD VI

Q. Write down the correct words in each box.


1. What is Python’s 3 basic data types? Give an example for each type:

a. __________________ Ex: _________

b. __________________ Ex: _________

c. __________________ Ex: _________


NextGen International Coding and Engineering
(NICE) School & College
Worksheet

Student’s Name: Subject: Python Programming Language Date:


Teacher’s Name: Jahanara Taznina Orin Roll: Class: STD VI

1
Instruction: Write down answers of flowing questions in copy

(Desire output: Addition Result)

Note: Write answers 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 [6]") Hawaiian

print(pizza) H

print(pizza[6]) aiian

print(pizza[2]) pizza[6]

print (pizza [3:]) Ha


Q. Using type () Cast change the data of the given code?
a. Write Code for changing datatype int into float
x=2
print(x)
Changed code:

4
a. Write Code for changing int into a string
x= 12
print(x)
Changed code:

a. Write Code for changing datatype string to float


x= “269.786”
print(x)
Changed code:

a. Write Code for changing datatype float to int


x=2.4
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

Student’s Name: Subject: Python Programming Language Date:


Teacher’s Name: Jahanara Taznina Orin Roll: Class: STD VI
Q. The type function returns the data type of an expression.
For each of these expressions, first predict the data type then use the type command to see if your prediction
was correct.
Expression Predicted data type Type command Type command
Result (√ or X)

"hello world" str type("hello world")

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)

(By Drawing a lines)

Q. For the following questions, write T for True or F for False:


a. _____ : You can add an int and a float.
b. _____: You can multiply two strings.
c. _____: You can subtract a float from an int.
d. _____: Python multiplication is represented by the symbol “x”.

e. _____: The output of the code: print(2 + “2”) is 4.


f. _____: If you multiply an int and a float, the result will be a float.
Q. Correct the following the code to answer the following questions:

a. What data type are each of the variables?

i. num_1: ____________

ii. num_2: ____________

iii. food_1: ____________

iv. food_2 : ____________

b. Write what each line will print out:

i. Line___________________________

ii. Line 8: ___________________________

iii. Line 9: ___________________________

iv. Line 10: __________________________

v. Line 11: __________________________

You might also like