Search Header Logo

Python - String and Lists

Authored by Anik Acharjee

Computers

Professional Development

Used 6+ times

Python - String and Lists
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

20 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

str1 = "Hello World"

result = ""

for char in str1:

if char.isalpha():

result += char.lower()

else:

result += char

print(result)

What will be the output of the above code?

hello world

HELLO WORLD

Hello World

hELLO wORLD

2.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

str2 = "Python is awesome"

result = ""

for i in range(len(str2)):

if i % 2 == 0:

result += str2[i].upper()

else:

result += str2[i].lower()

print(result)

What will be the output of the above code?

PyThOn iS AwEsOmE

pYtHoN iS AwEsOmE

PYTHON IS AWESOME

PytHon Is aWesoMe

3.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

str3 = "12345"

result = ""

for char in str3:

result += str(int(char) * 2)

print(result)

What will be the output of the above code?

246810

13579

Typecasting Error

12345246810

4.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

str4 = "Good Morning"

result = ""

for char in str4:

if char.isalpha():

result += char

print(result)

What will be the output of the above code?

Good Morning

GdMrng

Morning

GoodMorning

5.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

str5 = "abcdefg"

result = ""

for i in range(len(str5)):

if i % 2 != 0:

result += str5[i]

print(result)

What will be the output of this code?

bdfg

aceg

abcdefg

bdf

6.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

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

if len(my_list) > 3:

result = my_list[:3]

else:

result = my_list[::-1]

print(result)

What will be the output of the above code?

[1, 2, 3]

[5, 4, 3, 2, 1]

[1, 2, 3, 4, 5]

[1, 2]

7.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

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

if sum(my_list) > 20:

result = my_list[-1] * 2

else:

result = my_list[2]**2 + my_list[-2]**2

print(result)

What will be the output of this code?

7

10

25

2

Access all questions and much more by creating a free account

Create resources

Host any resource

Get auto-graded reports

Google

Continue with Google

Email

Continue with Email

Classlink

Continue with Classlink

Clever

Continue with Clever

or continue with

Microsoft

Microsoft

Apple

Apple

Others

Others

Already have an account?