wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Python Intern

Total questions: 65

Worksheet time: 1hrs 5mins

Name
Class
Date
1.

How to define a list in python ?

a)

my list=[1,2,3]

b)

my_list={1,2,3)

c)

my_list=[1,2,3]

d)

mylist=1,2,3

2.

How to add number 10 to this list?

myList=[1,2,3,4]

a)

myList.append(10)

b)

myList.insert(0,10)

c)

both correct

d)

none of the answers is correct

3.

myList=["ahmed","alaa,"mostafa","Malak","Hajar","leen"]

how to change values ("mostafa","Malak","Hajar") with values

("ahlam","Momen,"asmaa")

PLEASE KEEP SPACE BETWEEN THE TWO LINES THAT YOU WILL WRITE

(a)  

4.

How to remove "ahmed" from this list ?

myList=["ahmed","alaa","mostafa","Malak","Hajar","leen"]

a)

myList.delete

("ahmed")

b)

myList.remove

("ahmed")

c)

myList.delete

(0)

d)

myList.remove

(0)

5.

How to sort this list?

myList=[2,5,3,1,4,6]

(a)  

6.

x=4

y=4

if x>y:

print("yes")

elif x<y: print("No")

else: print("no condition met")

what will be the output?

a)

yes

b)

no

c)

no condition met

d)

error

7.

firstname="ahlam"

secondname="samir"

if (firstname==secondname):

print("true")

else:

print("false")

a)

true

b)

false

c)

error

8.

secondchar='a'

firstchar='A'

if (secondchar==firstchar):

print("yes")

else:

print("NO")

a)

yes

b)

no

c)

error

9.
To create a newline at the end of prompt, you can use which of the following expressions?
a)
\new
b)
\n
c)
\break
d)
\return
10.
The number or word we give to a variable
a)
Value
b)
Bug
c)
Information
d)
Text
11.
What symbol is used in python to assign values to a variable?
a)
equals =
b)
plus + 
c)
forward slash /
d)
asterisk *
12.
A syntax error means your code has a 'grammar' mistake or you used symbols/operations incorrectly
a)
True
b)
False
13.
What is the name of the environment in Python that write your programs and then test them out?
a)
Shell
b)
Window
c)
IDLE
d)
CLI
14.

What is the name of this symbol (>>>)?

a)

Chevrons

b)

Hash tags

c)

Colon

d)

Semi Colon

15.
What does the print function do in python?
a)
It's a variable.
b)
It can input data.
c)
It displays something like a string or integer
d)
It loops the code.
16.
What symbol do you use to make a comment in Python?
a)
@
b)
¬
c)
;
d)
#
17.

What does the following code do? myAge = int (myAge)

a)

Converts the var (variable) myAge to a string

b)

Converts the var (variable) myAge to a integer

c)

Converts the var (variable) myAge from a integer to a string

d)

Converts the var (variable) myAge to if statement

18.
Python identifies blocks of code by
a)
BEGIN and END keywords
b)
{ and }
c)
aligning up the starts of lines (indentation)
d)
guessing
19.
If you want more than one option for your code, what do you use (after if)?
a)
elif
b)
else
c)
ifif
20.
runs code line by line and checks for errors
a)
interpreter
b)
variable
c)
modulo
d)
boolean
21.
surrounds multi-line comments
a)
"""
b)
**
c)
#
d)
%
22.
a line of text that Python won't try to run as code
a)
comment
b)
modulo
c)
variable
d)
boolean
23.
a data type than can have one of two values: True or False
a)
boolean
b)
variable
c)
modulo
d)
interpreter
24.
The correct way to write a variable in Python?
a)
my_variable = 10
b)
my variable = 10
c)
my_variable is 10
d)
my_variable: 10
25.
In python the ' STRING data type' can be defined as...?
a)
holds alphanumeric text
b)
hold whole numbers
c)
holds numbers with a decimal point
d)
holds either a true or false value
26.
In python the ' FLOAT data type' can be defined as...?
a)
holds alphanumerical data
b)

holds whole numbers

c)

holds a decimal point in a number

d)
hold either true or false
27.
If we needed to store information such as a POSTCODE in PYTHON, what data type would we use?
a)
String (alphanumerical)
b)
Float (decimal point)
c)
Boolean (true or false)
28.
What is the correct definition for 'pseudo code?'
a)
a notation resembling a complex programming language, used in program design.
b)
a notation resembling a simplified programming language, used in program design.
29.
what is the code for a STRING in python?
a)
str
b)
stri
c)
stg
30.
what is correct code for INTEGER in python?
a)
in
b)
ing
c)
int
31.
What best defines an IF statement in python?
a)
Is an embedded string with a variable
b)
An IF statement checks to see if a statement is true or false and then does one of two things depending on the result.
32.

What is the maximum length of a Python identifier?

a)

32

b)

16

c)

128

d)

No fixed length is specified

33.

What will be the output of the following code snippet?

print(2**3 + (5 + 6)**(1 + 1))

a)

129

b)

8

c)

121

d)

None of the above

34.

What will be the datatype of the var in the below code snippet?

var = 10

print(type(var))

var = "Hello"

print(type(var))

a)

str and int

b)

int and int

c)

str and str

d)

int and str

35.

How is a code block indicated in Python?

a)

Brackets

b)

Indentation

c)

Key

d)

None of the above

36.

What will be the output of the following code snippet?

print(type(5 / 2))

print(type(5 // 2))

a)

float and int

b)

int and float

c)

float and float

d)

int and int

37.

Which of the following concepts is not a part of Python?

a)

Pointers

b)

Loops

c)

Dynamic Typing

d)

All of the above

38.

Which of the following statements are used in Exception Handling in Python?

a)

Try

b)

Except

c)

Finally

d)

All of the above

39.

Which of the following types of loops are not supported in Python?

a)

For

b)

While

c)

Do-While

d)

None of the above

40.

Which of the following is the proper syntax to check if a particular element is present in a list?

a)

If ele in list

b)

If not ele not in list

c)

Both A and B

d)

None of the above

41.

Which of the following functions converts date to corresponding time in Python?

a)

strptime ( )

b)

strftime ( )

c)

Both A and B

d)

None of the above

42.

What will be the output of the following Python function?

len(["hello",2, 4, 6])

a)

6

b)

4

c)

3

d)

Error

43.

Which of the following is a Python tuple?

a)

[1,2,3,4]

b)

{1,2,3,4}

c)

(1,2,3,4)

d)

none of these

44.

To add a new element to a list we use which Python command?

a)

list1.addEnd(5)

b)

list1.add(5)

c)

list1.append(5)

d)

list1.addLast(5)

45.

What will be the output of the following Python expression?

range(5,20,5)

a)

5,10,15

b)

5,10,15,20

c)

5,20,5

d)

5,

46.

 

What will be the datatype of the var in the below code snippet?

var = 10

print(type(var))

var = "Hello"

print(type(var))

a)

float and str

b)

int and int

c)

str and str

d)

int and str

47.

 

What will be the output of the following code snippet?

example = ["Sunday", "Monday", "Tuesday", "Wednesday"]

print(example[-3:-1])

a)

"Sunday", "Monday"

b)

"Monday", "Tuesday", "Wednesday"

c)

"Sunday"

"Monday"

"Tuesday"

"Wednesday"

d)

"Monday" "Tuesday"

48.

Which of the following are valid escape sequences in Python?

a)

\n

b)

\\

c)

\t

d)

all of these

49.

What is the output of the following program?

x = 123

for i in x:

     print(i)

a)

1 2 3

b)

3

c)

error

d)

none of these

50.

Which of the following words cannot be a variable in python language?

a)

_val

b)

Val

c)

print

d)

_try_

51.

What will be the output of the following Python code?

a)

a b c d

b)

0 1 2 3

c)

1 2 3 4

d)

none

52.

Study the following program:

i = 1:

while True:  

     if i%3 == 0:  

         break  

     print(i)  

Which of the following is the correct output of this program?

a)

1 2 3

b)

1 2

c)

invalid syntax

d)

1 2

53.

Which of the following option is not a core data type in the python language?

a)

List

b)

Dictionary

c)

Class

d)

all of these

54.

What will be the output of the following Python program?

a)

0

b)

0 1 2 3

c)

0 1 2

d)

0 1 2 3 4 5

55.

What happens when '2' == 2 is executed?

a)

No Output

b)

True

c)

False

d)

error

56.

What will be the output of the following Python code?

a)

aBCD

b)

abcd

c)

ABCD

d)

none of these

57.

Which module in Python supports regular expressions?

a)

re

b)

regex

c)

pyregex

58.

What does the function re.match do?

a)

matches a pattern at the start of the string

b)

matches a pattern at any position in the string

c)

such a function does not exist

59.

What will be the output of the following Python code?

sentence = 'we are humans'

matched = re.match(r'(.*) (.*?) (.*)', sentence)

print(matched.groups())

a)

(‘we’, ‘are’, ‘humans’)

b)

(we, are, humans)

c)

(‘we’, ‘humans’)

d)

‘we are humans’

60.

The expression a{5} will match _____________ characters with the previous regular expression.

a)

5 or less

b)

exactly 5

c)

5 or more

d)

exactly 4

61.

Enter Your Name

4 lines
62.

Enter Your Enrolment No

4 lines
63.

Enter Your Branch(CSE, CSE-DS, CSE-AIML, CSIT, CY, IT)

4 lines
64.

Enter Your Acropolis Email ID

4 lines
65.

Enter Your Batch(2026 or 2027)

4 lines