String Concatenation

first = "Hello"
second = "World"
print(first + second)

 

String Concatenation

first = "Hello"
second = "World"
print(first + second)

Hello World

Concatenating Numbers

text = "Your total is $"
value = 2.75
print(text + str(value))

 

Concatenating Numbers

text = "Your total is $"
value = 2.75
print(text + str(value))

Your total is $2.75

Concatenating Numbers

text = "Your total is $"
value = 2.75
print(text + value)

 

Concatenating Numbers

text = "Your total is $"
value = 2.75
print(text + value)

Traceback (most recent call last):
File "tutor.py", line 3, in <module>
    print(text + value)
TypeError: must be str, not float

String Formatting

name = input("Enter your name: ")
print("Hello {}".format(name))


String Formatting

name = input("Enter your name: ")
print("Hello {}".format(name))

Enter your name:  

String Formatting

name = input("Enter your name: ")
print("Hello {}".format(name))

Enter your name: Willie Wildcat

String Formatting

name = input("Enter your name: ")
print("Hello {}".format(name))

Enter your name: Willie Wildcat
Hello Willie Wildcat

String Formatting

name = input("Enter your name: ")
print("Hello {}".format(name))

Enter your name: Willie Wildcat
Hello Willie Wildcat

String Formatting

name = input("Enter your name: ")
print("Hello {}".format(name))

Enter your name: Willie Wildcat
Hello Willie Wildcat

String Formatting

name = input("Enter your name: ")
print("Hello {}".format(name))

Enter your name: Willie Wildcat
Hello Willie Wildcat

String Formatting

name = input("Enter your name: ")
print("Hello {}".format(name))

Enter your name: Willie Wildcat
Hello Willie Wildcat

String Formatting

text_one = input("Enter the price of one item: ")
price = float(text_one)
text_two = input("Enter the quantity of items: ")
quantity = int(text_two)
cost = price * quantity
print("{} items at ${} each is ${} total".format(quantity, price, cost))



String Formatting

text_one = input("Enter the price of one item: ")
price = float(text_one)
text_two = input("Enter the quantity of items: ")
quantity = int(text_two)
cost = price * quantity
print("{} items at ${} each is ${} total".format(quantity, price, cost))

Enter the price of one item: 2.75
Enter the quantity of items: 3
3 items at $2.75 each is $8.25 total