1. Learn
  2. /
  3. Courses
  4. /
  5. Regular Expressions in Python

Exercise

Literally formatting

While analyzing the text from Wikipedia pages, you read that Python 3.6 introduced f-strings.

You remember that you've created a website that displayed data science facts but it was too slow. You think that it could be due to the string formatting you used. Because f-strings are very fast and easy to use, you decide to rewrite that project.

The variables field1, field2 and field3 containing character strings as well as the numeric variables fact1, fact2, fact3 and fact4 have been saved.

If you want to explore the variables, you can use print() to view them in the IPython Shell.

Instructions 1/3

undefined XP
  • 1

    Complete the f-string to include the variable field1 with quotes and the variable fact1 as a digit.

  • 2

    Complete the f-string to include the variable fact2 using exponential notation, and the variable field2.

  • 3

    Complete the f-string to include field3, fact3 rounded to 2 decimals, and fact4 rounded to one decimal.