• Courses
  • Tutorials
  • Jobs
  • Practice
  • Contests

Special functions Python

Question 1

Q1-numbers = [1, 2, 3, 4, 5]
squares = list(map(lambda x: x**2, numbers))
What does the squares list contain after executing the code?

  • A) [1, 2, 3, 4, 5]

  • B) [1, 4, 9, 16, 25]

  • C) [2, 4, 6, 8, 10]

  • D) [0, 1, 4, 9, 16]

Question 2

Q2-words = ["apple", "banana", "cherry"]
filtered_words = list(filter(lambda x: len(x) > 5, words))
What is the value of filtered_words after executing the code?

  • A) ["apple"]

  • B) ["banana"]

  • C) ["cherry"]

  • D) ["banana", "cherry"]

Question 3

Q3-nums1 = [1, 2, 3]
nums2 = [4, 5, 6]
result = list(zip(nums1, nums2))
What is the value of result after executing the code?

  • A) [(1, 4), (2, 5), (3, 6)]

  • B) [5, 7, 9]

  • C) [(1, 2, 3), (4, 5, 6)]

  • D) [1, 2, 3, 4, 5, 6]

Question 4

Q4-numbers = [1, 2, 3, 4, 5]
squared_odd = list(map(lambda x: x**2, filter(lambda x: x % 2 != 0, numbers)))
What does the squared_odd list contain after executing the code?

  • A) [1, 9, 25]

  • B) [1, 4, 9, 16, 25]

  • C) [2, 4]

  • D) [9, 25]

Question 5

Q5-numbers = [1, 2, 3, 4, 5]
product = lambda x, y: x * y
result = reduce(product, numbers)
What is the value of result after executing the code?

  • A) 120

  • B) 15

  • C) 30

  • D) 0

Question 6

Q6-What does the ord function in Python do?

  • A) Rounds a floating-point number to the nearest integer

  • B) Returns the Unicode code point of a character

  • C) Converts a number to its hexadecimal representation

  • D) Finds the absolute value of a number

Question 7

Q7-char = 'A'
ascii_value = ord(char)
What is the value of ascii_value after executing the code?

  • A) 65

  • B) 66

  • C) 67

  • D) 68

Question 8

Q8-code_point = 97
character = chr(code_point)
What is the value of character after executing the code?

  • A) 'A'

  • B) 'B'

  • C) 'a'

  • D) 'b'

Question 9

Q9-text = "Python"
ascii_values = [ord(char) for char in text]
What is the value of ascii_values after executing the code?

  • A) [80, 121, 116, 104, 111, 110]

  • B) [112, 121, 116, 104, 111, 110]

  • C) [72, 101, 108, 108, 111, 32]

  • D) [65, 66, 67, 68, 69, 70]

Question 10

Q10-What is the result of the expression chr(ord('A') + 3)?

  • A) 'D'

  • B) 'E'

  • C) 'B'

  • D) 'C'


     

There are 10 questions to complete.

Last Updated :
Take a part in the ongoing discussion