Code
# Question
= 'What is Newton\'s 1st law of motion?'
q1
# Answer the question by defining a new string variable.
# Print your answer.
π Course Home | β‘οΈ Next Session |
π Practice 2. In the cell below, answer the question by defining a new string variable. Use the print()
command to output your answer.
# Question
= 'What is Newton\'s 1st law of motion?'
q1
# Answer the question by defining a new string variable.
# Print your answer.
Assign your first and last names to variables and use the +
operator to combine them into a single variable. Practice capitalizing the first letter and then the entire string. Print your answers.
π Practice 4 Use the code below to write a formatted string that prints the sentence My name is [YOUR FIRST NAME]. I am [YOUR AGE] years old.
, inputing your name and age. Replace first
with the name of the variable you assigned to your first name in the previous question. Replace age
with your age as an integer.
π Practice 5.
Collect some facts about your classroom neighbor. Assign these facts to variables and create 3-4 print statements using format strings.
print(fβ{name} has traveled to {country} {this_many} timesβ)
π Practice 6.
Use the input function to create two variables: one corresponding to the day on which you were born based on user input and one corresponding to the month you were born.
Convert both variables to floats and assign the float versions to new variables. Lastly, use one of the boolean operators to evaluate which variable is greater β the day or the month β and print the result.