0% found this document useful (0 votes)
227 views1 page

2.3 Code Practice Question 1

Uploaded by

zeshan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
227 views1 page

2.3 Code Practice Question 1

Uploaded by

zeshan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

CS Python Fundamentals

(f5f974)
! 2.3 Code Prac!ce:
"
Ques!on 1

2.3 Code Prac!ce: Ques-


!on 1

Due No Due Date Points 1


Submi!ng an external tool

Instruc!ons

Write a program that prompts the


user to input
two POSITIVE numbers — a
dividend (numerator) and a divisor
(denominator). Your program
should then divide the numerator
by the denominator. Lastly, your
program will add the quo!ent and
the remainder together.

Sample Run:

Input the dividend: 10


Input the divisor: 4
The quotient + the remainder i
s 4.0

Hint: If you use division (/) to


calculate the quo!ent, you will
need to use int() to remove the
decimals. You can also use integer
division (// ), which was
introduced in Ques!on 5 of
Lesson Prac!ce 2.3.

Once you've calculated the


quo!ent, you will need to
use modular division (%) to
calculate the remainder.
Remember to clearly define the
data types for all inputs in your
code. You may need to use int(
) and str( ) in your solu!on.

int( ): When you divide the


numerator and the divisor using /,
make sure that the result is an
integer.

str( ): A"er using modular division,


you can transform the quo!ent
and remainder back into strings to
display the result in the print()
command.
STATUS

SUBMITTED 100% SAVE


INSTRUCTIONSRUN CODE
1 dividend = int(input
("Input the dividend
: ")) Write a program
2 divisor = int(input that prompts the
("Input the divisor:
")) user to input two
3 print ("The quotient + POSITIVE
the remainder is " +
str((dividend numbers — a
//divisor +
dividend%divisor))) dividend
4 ... (numerator) and a
divisor
(denominator).
Your program
∥ should then
divide the
numerator by the
denominator.
Lastly, your
program will add
the quotient and
the remainder
together.

Sample Run:

Input the div

Input the div

#Previous Next$

You might also like