Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. What is the output for: [x for x in range(10) if x%2==0] Group of answer choices 1,2,3,4,5,6,7,8,9,10 0,2,4,6,8,10 0,2,4,6,8 0,1,2,3,4,5,6,7,8,9 2. What is the

1. What is the output for:

[x for x in range(10) if x%2==0]

Group of answer choices

  • 1,2,3,4,5,6,7,8,9,10
  • 0,2,4,6,8,10
  • 0,2,4,6,8
  • 0,1,2,3,4,5,6,7,8,9

2. What is the output for:

sentence = "Walmart has a lower acceptance rate than Harvard"

print({word: len(word) for word in sentence.split() if len(word)>6})

Group of answer choices

  • {'Walmart': 7, 'acceptance': 10, 'Harvard': 7}
  • {'acceptance': 10}
  • syntax error

3. In Python, which keyword is used to start a function?

Group of answer choices

  • function
  • def
  • try
  • import

4. What is the output:

def func(x, num = 2):

print(x * num)

func(3)

Group of answer choices

  • 3
  • 6
  • Syntax error
  • None of the above

5. In Python language, function can be passed as argument to another function.

Group of answer choices

  • True
  • False

6. What is the output?

exp = lambda x: x**3

print(exp(2))

Group of answer choices

  • 6
  • 222
  • 8
  • None of the above

7. What is the output?

x = [1, 2, 3, 4, 5]

for i in filter(lambda n: True if n%2==0 else False, x):

print(i)

Group of answer choices

  • 1 2 3 4 5
  • 1 3 5
  • 2 4
  • 5 4 3 2 1

8. What is the output?

x = ['mike', 'jackson', 'tom']

print(sorted(x, key = lambda e: len(e), reverse=True))

Group of answer choices

  • ['jackson', 'mike', 'tom']
  • ['mike', 'jackson', 'tom']
  • ['tom', 'jackson', 'mike']

9. What is the output?

x = ['mike', 'jackson', 'tom']

for i in map(lambda e:len(e), x):

print(i)

Group of answer choices

  • 3, 7, 4
  • 4, 7, 3
  • 'mike', 'jackson', 'tom'
  • 'tom', jackson', 'mike'

10. What is the output?

[x**2 for x in range(5)]

Group of answer choices

  • [0, 1, 2, 3, 4]
  • [1, 2, 3, 4, 5]
  • [0, 1, 4, 9, 16]
  • [1, 4, 9, 16, 25]

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Elementary Number Theory

Authors: Underwood Dudley

1st Edition

0486134873, 9780486134871

More Books

Students also viewed these Mathematics questions