Python - String and Lists

Python - String and Lists

Professional Development

20 Qs

quiz-placeholder

Similar activities

MS-900 2

MS-900 2

Professional Development

19 Qs

Python

Python

Professional Development

20 Qs

DECI - Week 13 - round

DECI - Week 13 - round

Professional Development

16 Qs

File Extensions

File Extensions

9th Grade - Professional Development

20 Qs

JAVA - Arrays

JAVA - Arrays

University - Professional Development

15 Qs

Logika & Pemrograman (ID)

Logika & Pemrograman (ID)

10th Grade - Professional Development

20 Qs

Colors_unit2

Colors_unit2

Professional Development

20 Qs

Basis Data Kelas XII

Basis Data Kelas XII

Professional Development

19 Qs

Python - String and Lists

Python - String and Lists

Assessment

Quiz

Computers

Professional Development

Medium

Created by

Anik Acharjee

Used 6+ times

FREE Resource

AI

Enhance your content

Add similar questions
Adjust reading levels
Convert to real-world scenario
Translate activity
More...

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

Create a free account and access millions of resources

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

By signing up, you agree to our Terms of Service & Privacy Policy

Already have an account?