# 5 Questions in Python

Can you help me understand this Python question?

The code:

#QUESTION 1

# complete the following code so that it asks the user for their first name and last name through the console

# make the print statement complete by printing ‘your name is ‘ [firstname] [middle initial]. [lastname] where the first letter of all is capitalized

# so my name would be Nathan D. Green

first_name=

last_name=

middle_name=

#QUESTION 2

#make the following function print the right answers

def calculations(a,b):

subtraction=

division=

multiplication=

modulus=

print (“a plus b = “)

print (“a minus b = “)

print (“a divided by b = “)

print (“a multiplied by b = “)

print (“the remainder of a divided by b = “)

calculations(9,3)

calculations(2,5)

#QUESTION 3

#write a loop two ways (1 for loop and 1 while loop)

#Ask the user for a number

#print every number from 1 to the number entered (and including the number entered)

#for instance

#the user enters 10 on the command prompt

#print

#1

#2

#…

#10

#Bonus points (4) write a third loop that only prints out the odd numbers in the given range

#QUESTION 4

# define a list that contains the colors of the rainbow (red, orange, yellow, green, blue, indigo, violet)

# Ask the User for their favorite color and replace blue with it

# Loop through the list and print out the new colors of the rainbow exactly as describe below (numbers and all)

#THE NEW COLORS OF THE RAINBOW ARE

#1:red

#2:orange

#3:yellow

#4:green

#5:whatever the user entered

#6:indigo

#7:violet

#QUESTION 5

#make the following function print the right answer

#In this case if it is 2020 and the user is 21, they were born in 1999

#It should print

#You were born in 1999

#the second example

#you were born in 2002

def year_of_birth(age,current_year):

print(year_of_birth(21,2020))

print(year_of_birth(18,2020))

### “Looking for a Similar Assignment? Order now and Get a Discount! 