Page 1 of 1

Python: String Variables and Print Statements

Posted: Mon Apr 06, 2026 6:46 pm
by Jason

Code: Select all


person_name = str("Homer Simpson")

person_career_name = str)"energy plant worker")

# String variables don't have to be declared, and they are in this example.

print(f"{person_name} has a career as a {person_career_name}.")

# The above statement prints out the sentence "Homer Simpson has a career as a energy plant worker." (no parenthesis)