Addition in variables - Introduction to Python: Absolute Beginner Module 1 Video 11

preview_player
Показать описание
use addition in print ()
Use print() to show the results of multiple lines of output

Example
addition in variable assignments and in print()
# [ ] review & run code for assigning variables & using addition
add_two = 34 + 16
first_name = "Alton"
greeting = "Happy Birthday " + first_name

print(add_two)
print(greeting)
# [ ] review & run code for Integer addition in variables and in a print function
int_sum = 6 + 7
print(int_sum)
print(11 + 15)
print()
# string addition in variables and in print()function
hat_msg = "I do not wear " + "a hat"
print(hat_msg)
print("at " + "dinner")
Task 3: multi-part
create Integer addition and string addition output
# [ ] perform string addition in the variable named new_msg (add a string to "my favorite food is ")
new_msg = "My favorite food is"
print(new_msg)

# [ ] perform Integer addition in the variable named new_msg (add 2 or more Integers)
new_sum = 0
print(new_sum)

# [ ] create and print a new string variable, new_msg_2, that concatenates new_msg + a literal string
Рекомендации по теме
join shbcf.ru