Table of Contents

#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}")
				
			

Free Community

Join 1,000+ AI Automation Builders

Weekly tutorials, live calls & direct access to Ryan & Matt.

Join Free →

Keep Learning

Streamlit Async

Streamlit runs Python scripts top-to-bottom when ever a user interacts with widget.Streamlit is synchronous by default, meaning each function waits for the...

Streamlit Caching

Streamlit runs your script from top to bottom whenever you interact with the app.This execution model makes development super easy. But it...

Streamlit Tutorial

Streamlit can help businesses automate a ton of tasks in a short amount of time. It essentially is a quick UI you...

Gradient boosting classifier

Gradient Boosting is an ensemble technique that builds a strong model by combining multiple weak decision trees. While it may seem similar...