CS5001 / CS5003:
Intensive Foundations of Computer Science
'''This program asks for a person's name and age, and then prints their age for every year until 2030'''
CURRENT_YEAR = 2019
END_YEAR = 2030
name = input("What is your name? ")
age = int(input("What is your age? "))
print("\nHello, {}!\n".format(name))
print("Year Age")
for year in range(CURRENT_YEAR, END_YEAR + 1):
print("{} {}".format(year, age + year - CURRENT_YEAR))
print("Goodbye!")
Profanity!
print
function, which means that whatever we put inside the parentheses gets printed to the screen.
print("Hello, World!")
# Ask for a user's name, and print it
name = input("What is your name? ")
print(name)
Hello
," and then the name? How would we do that?
Hello, Name!
", all on one line?
print
function.print
function looks like this:{}
.# Ask for a user's name, and print it
name = input("What is your name? ")
???
print(name)
print("Hello, {}!".format(name))
age
, which we use to store the user's age.# Ask for a user's name and age, and print them
name = input("What is your name? ")
age = input("What is your age? ")
print("Hello, {}, you look great for being {} years old!".format(name, age))
# Ask for a user's name and age, and print them
name = input("What is your name? ")
age = input("What is your age? ")
print("Hello, {}, you look great for being {} years old!".format(age, name))
age
, which we use to store the user's age.# Ask for a user's name and age, and print them
name = input("What is your name? ")
age = input("What is your age? ")
print("Hello, {}, you look great for being {} years old!".format(name, age))
# Ask for a user's name and age, and print them
name = input("What is your name? ")
age = input("What is your age? ")
print("Hello, {}, you look great for being {} years old!".format(age, name))