What is the purpose of f-strings in Python?

Quiz on f-strings in Python

Quiz
•
Computers
•
12th Grade
•
Easy
Haden Hiser
Used 4+ times
FREE Resource
8 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
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]}")
Similar Resources on Quizizz
10 questions
File Handling

Quiz
•
12th Grade
10 questions
Линейные алгоритмы

Quiz
•
9th - 12th Grade
10 questions
Python Review - Functions

Quiz
•
9th - 12th Grade
13 questions
Unit 14 - Geek Stuff IT Service Strategy

Quiz
•
12th Grade
10 questions
MOAC Excel 2016 Lesson 03

Quiz
•
8th - 12th Grade
10 questions
Java Print Statements Warm-Up

Quiz
•
9th - 12th Grade
10 questions
Dadakan quiz 1

Quiz
•
12th Grade
10 questions
Arrays and Lists

Quiz
•
6th - 12th Grade
Popular Resources on Quizizz
15 questions
Multiplication Facts

Quiz
•
4th Grade
20 questions
Math Review - Grade 6

Quiz
•
6th Grade
20 questions
math review

Quiz
•
4th Grade
5 questions
capitalization in sentences

Quiz
•
5th - 8th Grade
10 questions
Juneteenth History and Significance

Interactive video
•
5th - 8th Grade
15 questions
Adding and Subtracting Fractions

Quiz
•
5th Grade
10 questions
R2H Day One Internship Expectation Review Guidelines

Quiz
•
Professional Development
12 questions
Dividing Fractions

Quiz
•
6th Grade