Quiz on f-strings in Python

Quiz on f-strings in Python

12th Grade

8 Qs

quiz-placeholder

Similar activities

DA METER REVIEW #4

DA METER REVIEW #4

12th Grade

12 Qs

Unit 1 Vocab Review

Unit 1 Vocab Review

8th - 12th Grade

9 Qs

PYTHON BASIC 8 - 9

PYTHON BASIC 8 - 9

12th Grade

10 Qs

Tutoring PY Practice 2025

Tutoring PY Practice 2025

12th Grade

10 Qs

Python Basics

Python Basics

6th Grade - University

10 Qs

AP CSP Python Quiz 1

AP CSP Python Quiz 1

10th - 12th Grade

11 Qs

Básicas de Python 4

Básicas de Python 4

12th Grade

10 Qs

Java String Methods

Java String Methods

10th - 12th Grade

10 Qs

Quiz on f-strings in Python

Quiz on f-strings in Python

Assessment

Quiz

Computers

12th Grade

Easy

Created by

Haden Hiser

Used 4+ times

FREE Resource

8 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the purpose of f-strings in Python?

To format strings and embed expressions directly into strings

To create functions

To manage file operations

To handle exceptions

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which version of Python introduced f-strings?

Python 2.7

Python 3.8

Python 3.6

Python 3.9

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

How do you create an f-string?

Prefix the string with the letter 's'

Use the format() method

Use the str() function

Prefix the string with the letter 'f'

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the output of the following code? val = 'Geeks' print(f"{val}for{val} is a portal for {val}.")

GeeksforGeeks is a portal for Geeks.

Geeks for Geeks is a portal for Geeks.

GeeksforGeeks is a portal for Geeks

Geeks for Geeks is a portal for Geeks

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

How can you print today's date using f-strings and the datetime module?

print(f"{datetime.datetime.today():%B %d, %Y}")

print(f"{datetime.date.now():%B %d, %Y}")

print(f"{datetime.date.today():%B %d, %Y}")

print(f"{datetime.datetime.now():%B %d, %Y}")

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What will be the output of the following code? english = 78 maths = 56 hindi = 85 print(f"Ram got total marks {english + maths + hindi} out of 300")

Ram got total marks 219 out of 300

Ram got total marks 219 out of 100

Ram got total marks 219 out of 200

Ram got total marks 219 out of 400

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which of the following is NOT allowed in f-strings?

Using expressions

Using variables

Using curly braces

Using backslashes directly

8.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

How can you print a dictionary's key-value pair using f-strings?

print(f"Id of {Geek['Name']} is {Geek['Id']}")

print(f"Id of {Geek["Name"]} is {Geek["Id"]}")

print(f"Id of {Geek[Name]} is {Geek[Id]}")

print(f"Id of {Geek[Name]} is {Geek[Id]}")