Python F String
#f string
#not a string generated by user
#double quotes the best
#12 examples
#Ex 1: Printing a string
name = 'nolan'
print(f"Hello,{name}")

#ex 2: multiple strings
state = 'Florida'
print(f"Hello, {name} from {state}")

#Ex 3: functions or methods in the f string
print(f"Hello, {name.upper()}")

#Ex 4: (SORT OF ADVANCED CAN SKIP)
class Player: def __init__(self, name, team): self.name = name self.team = team
player1 = Player("Ruth", "Yankees")
print(f"Player: {player1.name}, Team: {player1.team}")

#Ex: 5 Inline Expressions
print(f"1 squared is {1**2}.")

#Ex 6: calculations a = 5 b =13 print(f"what is {a} * {b}? It's {a * b}")

#ex 7: Format Specifiers Padding x = 5
print(f"format {x:02}")

#ex 8: Format Specifiers Precision x = 5.111111111111111 print(f"format {x:.4}")

#ex: 9 datetime
from datetime import datetime birthday = datetime(2011, 1, 1) formatted_birthday = birthday.strftime("%B %d, %Y") print(f"Birthday: {formatted_birthday}")

#ex 10: Dictionary
player = {'name': 'Kershaw', 'team':'dodgers', 'number':22}
player_print = f"All Star {player['name']}, team {player['team']}, number{player['number']}"
print(player_print)

#ex 11 Multiline f-strings: name = "Kershaw" number = 22 team = dodgers player = f""" Name: {name} number: {number} team: {team}
print(player)

#ex 12 loops
for i in range(3, 7): print(f"Number {i}: {i**2}")

Ryan is a Data Scientist at a fintech company, where he focuses on fraud prevention in underwriting and risk. Before that, he worked as a Data Analyst at a tax software company. He holds a degree in Electrical Engineering from UCF.