Converting Cents to Dollars in Python – C# Programming Example
Basic Python 3

Converting Cents to Dollars in Python

How to convert cents to dollars? Firstly we should know how many cents is how many dollars and cents.

Answer: 1 dollar is equal to 100 cent.

Write a statement that prints the value of price in the form “X dollars and Y cents” on a line by itself.

So, if the value of price was 1002, your code would print “10 dollars and 2 cents”.

If the value was 511 it would print “5 dollars and 11 cents”.

Solution 1:

 

Solution 2: 

 

Output: I entered cents value as 1010  

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: