Python Exam Questions: Data Types, Operators, and Functions, Exams of Nursing

A series of python exam questions with correct answers, covering fundamental concepts such as data types (numbers, strings, lists, tuples, dictionaries), operators, string manipulations, list operations, and built-in functions. It includes questions on converting between data types, performing calculations, and manipulating strings and lists. The questions are designed to test understanding of basic python syntax and functionality, making it a useful resource for students preparing for exams or quizzes on python programming. It also covers random number generation and string functions. Useful for university and high school students.

Typology: Exams

2024/2025

Available from 07/15/2025

Lectjoshua
Lectjoshua 🇺🇸

4.5

(9)

24K documents

1 / 7

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Python Exam Questions PART 1 with
correct answers
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]
pf3
pf4
pf5

Partial preview of the text

Download Python Exam Questions: Data Types, Operators, and Functions and more Exams Nursing in PDF only on Docsity!

Python Exam Questions PART 1 with

correct answers

  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]
  1. What is the output of print(list[0]) if list =[ 'abcd', 786 , 2.23]? - CORRECT ANSWER✔✔-abcd
  2. What is the output of print(list[1:3]) if list=[ 'abcd', 786 , 2.23]? - CORRECT ANSWER✔✔- [786, 2.23]
  3. What is the output of print(list[2:]) if list=[ 'abcd',786, 2.23]? - CORRECT ANSWER✔✔-[2.23]
  4. What is the output of print (tinylist * 2) if tinylist = [123, 'john']? - CORRECT ANSWER✔✔- [123, 'john',123, 'john']
  5. Which of the following is correct about tuples in Python? - CORRECT ANSWER✔✔-***
  6. What is the output of print(myTuple) if myTuple = ('abcd',786,2.23)? - CORRECT ANSWER✔✔-('abcd',786,2.23)
  7. What is the output of print(myTuple[1:3]) if myTuple=('abcd',786,2.23)? - CORRECT ANSWER✔✔-(786, 2.23)
  8. What is the output of print (myTuple[0]) if myTuple = ('abcd',786,2.23)? - CORRECT ANSWER✔✔-abcd
  9. Which function obtains all the keys from a dictionary? - CORRECT ANSWER✔✔-keys()
  10. Which function obtains all the values from a dictionary? - CORRECT ANSWER✔✔-values()
  11. Which function converts a string to an int? - CORRECT ANSWER✔✔-int("string")
  1. Which operator evaluates True if it does not find a variable sequence? - CORRECT ANSWER✔✔-not in
  2. Which statement stops and transfers to the statement after the loop? - CORRECT ANSWER✔✔-break
  3. Which statement skips the loop & retests prior to reiterating? - CORRECT ANSWER✔✔- continue
  4. Which statement is used when when you do not want any code to execute? - CORRECT ANSWER✔✔-exit() or pass()
  5. Which function returns a random item from a list, tuple, or string? - CORRECT ANSWER✔✔- random.choice()
  6. Which function returns a randomly selected element from range? - CORRECT ANSWER✔✔- random.randrange()
  7. Which function returns a random float between 0 and 1? - CORRECT ANSWER✔✔- random.random()
  8. Which function sets the starting value in generating random numbers? - CORRECT ANSWER✔✔-seed([x])
  9. Which function randomizes the items of a list in place? - CORRECT ANSWER✔✔- random.shuffle()
  1. Which function capitalizes first letter of string? - CORRECT ANSWER✔✔-title()
  2. Which function checks in a string that all characters are alphanumeric? - CORRECT ANSWER✔✔-isalnum()
  3. Which function checks in a string that all characters are digits? - CORRECT ANSWER✔✔- isdigit()
  4. Which function checks in a string that all characters are in lowercase? - CORRECT ANSWER✔✔-islower()
  5. Which function checks in a string that all characters are numeric? - CORRECT ANSWER✔✔- isnumeric()
  6. Which function checks in a string that all characters are whitespaces? - CORRECT ANSWER✔✔-isspace()
  7. Which function checks in a string that all characters are titlecased? - CORRECT ANSWER✔✔- istitle()
  8. Which function checks in a string that all characters are in uppercase? - CORRECT ANSWER✔✔-isupper()
  9. Which function merges elements in a sequence? - CORRECT ANSWER✔✔-join(seq)
  10. Which function obtains the length of the string? - CORRECT ANSWER✔✔-len()
  1. What is the function that returns the lowest index in list? - CORRECT ANSWER✔✔- list.index(obj)
  2. What is the function that inserts an object at given index in a list? - CORRECT ANSWER✔✔- list.insert(index,obj)
  3. What is the function that removes last object from a list? - CORRECT ANSWER✔✔- list.pop(obj=list[-1])
  4. What is the function that removes an object from a list? - CORRECT ANSWER✔✔- list.remove(obj)