View the step-by-step solution to:

Question

Problem 1

#The code below tries to calculate the quotient and remainder

#of a pair of

numbers. However, right now None is printing

#in several places throughout the code's execution. Fix the

#code so that it behaves as intended: it should print the

#quotient, remainder, then the message, "We're done!"

#

#HINT: There are a couple ways to d this, and some of those

#ways might be a little advanced right now. Note that 17 // 6

#will correctly calculate the quotient and num_1 % num_2 will

#correctly calculate the remainder.

#

#HINT 2: Click Reset to start over from scratch.


num_1 = 17

num_2 = 6


quotient = print("The quotient is", + (num_1 // num_2))

print(quotient)


remainder = print("The remainder is", (num_1 % num_2))

print(remainder)

c = a + b

final = print(c)

print(d)

print(print("We're done!"))


Problem 2

#The code below creates a variable named my_int and

#assigns to it a random number from 0 to 10. You

#don't need to worry about how this works; all you

#need to know is that my_int will have an integer

#as its value once this code is done.


import random

my_int = random.randint(0, 10)


#Do not edit the code above!

#

#The line below attempts to print the value of

#my_int, but currently it does not work. Fix

#this code so that it works and prints "The

#current value of my_int is:", followed by the

#value.


print("The current value of my_int is: " + my_int)


Problem 3

#In the code below, we've created two dates. The day in each

#date is chosen randomly. You don't need to worry about how

#this works; all you need to know is that when you start

#writing your code, you'll have access to two variables, each

#holding a date: earlier_date and later_date, and later_date

#is guaranteed to be later than earlier_date.

#

#omplete this code so that it creates a variable called

#days_between that stores the number of days between the two

#dates.

#

#Hint: You can find the number of days between two dates by

#subtracting the day number of the earlier date from the

#day number of the later date.


from datetime import date

import random

earlier_date = date(2017, 6, random.randint(1, 25))

later_date = date(2017, 6, random.randint(earlier_date.day + 1, 28))


#Do not modify the code above!



#rite your code here!

date = date.today()

days_between = str(later_date - earlier_date)


#If your code is working correctly, then the following line

#of code will print the correct number of dayes between the

#two dates. Notice that this line uses commas instead of plus

#signs, which is why it doesn't have to convert the dates to

#strings: Python does that implicitly when we use this syntax.

print("There are",days_between, "between", earlier_date, "and", later_date)


Problem 4

my_variable = "The value is Hello, world! and the class type is <class str>"


#You may modify the lines of code above, but don't move them!

#When you Submit your code, we'll change these lines to

#assign different values to the variables.

#

#The code above creates one variable. Right now, it's a

#string, but we might change it to be an integer, a float, or

#something else.

#

#Add a line of code below that will print the variable's value

#and type in a sentence like this:

#

#The value is Hello, world! and the type is <class 'str'>



#dd your lines of code here!


print (my_variable))


#When running your code, you should see the message on line

#14 printed. When submitting, we'll test your code with other

#values and types.

Top Answer

View the full answer
Screenshot_1.png

num 1 = 17
num 2 = 6
3
quotient = (num 1 // num 2)
4
print (&quot;The quotient is&quot;, + quotient)
5
remainder = (num 1 % num 2)
print (&quot;The remainder is&quot;, remainder)
print (&quot;We're...

Sign up to view the full answer

Why Join Course Hero?

Course Hero has all the homework and study help you need to succeed! We’ve got course-specific notes, study guides, and practice tests along with expert tutors.

-

Educational Resources
  • -

    Study Documents

    Find the best study resources around, tagged to your specific courses. Share your own to gain free Course Hero access.

    Browse Documents
  • -

    Question & Answers

    Get one-on-one homework help from our expert tutors—available online 24/7. Ask your own questions or browse existing Q&A threads. Satisfaction guaranteed!

    Ask a Question
Ask a homework question - tutors are online