PYTHON EXAM QUESTIONS AND ANSWERS (DATA SCIENCE) 2026 #1, Exams of Computer Science

PYTHON EXAM QUESTIONS AND ANSWERS (DATA SCIENCE) 2026 #1

Typology: Exams

2025/2026

Available from 02/09/2026

YourExamPlug
YourExamPlug 🇿🇦

1.4K documents

1 / 4

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
PYTHON EXAM QUESTIONS AND ANSWERS (DATA SCIENCE)
2026 #1
1. Which of the following data types are supported in Python? - correct answer The
following data type are *Supported*:
1 - Numbers
2 - String
3 - List
4 - Tuples
5 - Dictionary
2. Which of the following data types are *not* supported in Python? - correct answer
Slice
3. What is the output of print(str) if str = 'Hello World!'? - correct answer Hello World!
4. What is the output of print(str[0]) if str = 'Hello World!'? - correct answer H
5. What is the output of print(str[2:5]) if str = 'Hello World!'? - correct answer llo
6. What is the output of print(str[2:]) if str = 'Hello World!'? - correct answer llo World!
7. What is the output of print(str * 2) if str = 'Hello World!'? - correct answer Hello World!
Hello World!
8. What is the output of print(list) if list=[ 'abcd', 786 , 2.23]? - correct answer ['abcd', 786
, 2.23]
9. What is the output of print(list[0]) if list =[ 'abcd', 786 , 2.23]? - correct answer abcd
10. What is the output of print(list[1:3]) if list=[ 'abcd', 786 , 2.23]? - correct answer [786,
2.23]
11. What is the output of print(list[2:]) if list=[ 'abcd',786, 2.23]? - correct answer [2.23]
12. What is the output of print (tinylist * 2) if tinylist = [123, 'john']? - correct answer [123,
'john',123, 'john']
13. Which of the following is correct about tuples in Python? - correct answer ***
14. What is the output of print(mytuple) if mytuple = ('abcd',786,2.23)? - correct answer
('abcd',786,2.23)
pf3
pf4

Partial preview of the text

Download PYTHON EXAM QUESTIONS AND ANSWERS (DATA SCIENCE) 2026 #1 and more Exams Computer Science in PDF only on Docsity!

PYTHON EXAM QUESTIONS AND ANSWERS (DATA SCIENCE)

  1. Which of the following data types are supported in Python? - correct answer The following data type are Supported: 1 - Numbers 2 - String 3 - List 4 - Tuples 5 - Dictionary
  2. Which of the following data types are not supported in Python? - correct answer Slice
  3. What is the output of print(str) if str = 'Hello World!'? - correct answer Hello World!
  4. What is the output of print(str[0]) if str = 'Hello World!'? - correct answer H
  5. What is the output of print(str[2:5]) if str = 'Hello World!'? - correct answer llo
  6. What is the output of print(str[2:]) if str = 'Hello World!'? - correct answer llo World!
  7. What is the output of print(str * 2) if str = 'Hello World!'? - correct answer Hello World! Hello World!
  8. What is the output of print(list) if list=[ 'abcd', 786 , 2.23]? - correct answer ['abcd', 786 , 2.23]
  9. What is the output of print(list[0]) if list =[ 'abcd', 786 , 2.23]? - correct answer abcd
  10. What is the output of print(list[1:3]) if list=[ 'abcd', 786 , 2.23]? - correct answer [786, 2.23]
  11. What is the output of print(list[2:]) if list=[ 'abcd',786, 2.23]? - correct answer [2.23]
  12. What is the output of print (tinylist * 2) if tinylist = [123, 'john']? - correct answer [123, 'john',123, 'john']
  13. Which of the following is correct about tuples in Python? - correct answer ***
  14. What is the output of print(mytuple) if mytuple = ('abcd',786,2.23)? - correct answer ('abcd',786,2.23)
  1. What is the output of print(mytuple[1:3]) if mytuple=('abcd',786,2.23)? - correct answer (786, 2.23)
  2. What is the output of print (mytuple[0]) if mytuple = ('abcd',786,2.23)? - correct answer abcd
  3. Which function obtains all the keys from a dictionary? - correct answer keys()
  4. Which function obtains all the values from a dictionary? - correct answer values()
  5. Which function converts a string to an int? - correct answer int("string")
  6. Which function converts a string to a float? - correct answer float("string")
  7. Which function converts a string to a tuple? - correct answer tuple("string")
  8. Which function converts a string to a list? - correct answer list("string")
  9. Which function converts a sequence of tuples to dictionary? - correct answer dict()
  10. Which function converts an integer to a character? - correct answer chr()
  11. Which function converts an integer to an unicode character? - correct answer unichr()
  12. Which function converts a single character to its integer value? - correct answer ord()
  13. Which function converts an integer to hexadecimal string? - correct answer hex()
  14. Which operator performs exponential power calculation on operands? - correct answer **
  15. Which operator performs the division where the result an integer? - correct answer //
  16. Which operator evaluates True when operands refer to the same object? - correct answer == or is
  17. Which operator evaluates True if it does not find a variable sequence? - correct answer not in
  18. Which statement stops and transfers to the statement after the loop? - correct answer break
  1. Which function obtains the length of the string? - correct answer len()
  2. Which function converts a string to all lowercase? - correct answer {string}.lower()
  3. Which function removes all leading whitespace in a string? - correct answer lstrip()
  4. Which function returns the max character from a string? - correct answer max(str)
  5. Which function returns the min character from a string? - correct answer min(str)
  6. Which function replaces a substring in string with new string? - correct answer replace(old,new,[max])
  7. What is the output of [1, 2, 3] + [4, 5, 6]? - correct answer [1,2,3,4,5,6]
  8. What is the output of ['Hi!'] * 4? - correct answer ['Hi!','Hi!','Hi!','Hi!']
  9. What is the output of 3 in [1, 2, 3]? - correct answer True
  10. What is the output of L[2] if L = [1,2,3]? - correct answer 3
  11. What is the output of L[-2] if L = [1,2,3]? - correct answer 2
  12. What is the output of L[1:] if L = [1,2,3]? - correct answer [2,3]
  13. What is the function that compares elements of lists? - correct answer cmp(list1,list2)
  14. What is the function that returns the lowest index in list? - correct answer list.index(obj)
  15. What is the function that inserts an object at given index in a list? - correct answer list.insert(index,obj)
  16. What is the function that removes last object from a list? - correct answer list.pop(obj=list[-1])
  17. What is the function that removes an object from a list? - correct answer list.remove(obj)