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

Problem 1. (Separating Digits in An Integer) Write A Program That Inputs One

Uploaded by

曾燒餅
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)
41 views1 page

Problem 1. (Separating Digits in An Integer) Write A Program That Inputs One

Uploaded by

曾燒餅
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

Exercise #1

 Problem 1. (Separating Digits in an Integer) Write a program that inputs one


five-digit number, separates the number into its individual digits and prints
the digits separated from one another by three spaces each.
 [Hint: Use combinations of integer division and the remainder
operation.]
 For example, if the user types in 42139, the program should print
4 2 1 3 9

 Problem 2. Write a program that asks the user to enter a number of seconds
and then prints the same amount of time in days, hours, minutes, and
seconds. [Hint: Use the remainder operator]輸入總秒數,換算成日時分秒
輸出
 For example, 3667 seconds is equivalent to 0 days, 1 hour, 1 minute,
and 7 seconds.
 Print out the result in the format:
"0 day(s), 1 hour(s), 1 minute(s), and 7 second(s)."

 Problem 3. Input three sides (a, b, c) of a triangle, calculate the area of the
triangle
 area = sqrt(s(s – a)(s – b)(s – c)),
 where s = (a + b + c) / 2
 Import math module, use math.sqrt(x)

 You don’t need to turn in your homework, but you should practice all problems
because they may appear in the following exam.
 作業自己練習就好,不用繳交,之後考試可能會出現類似題目

You might also like