Python Programming: An Introduction to Computer Science
Python Programming: An Introduction to Computer Science
3rd Edition
ISBN: 9781590282779
Author: John Zelle
Publisher: Franklin Beedle & Associates
Question
Book Icon
Chapter 13, Problem 6PE
Program Plan Intro

Printing digits of a number

Program plan:

  • Define a class “BaseConversion”.
    • Define “init” function.
      • Declaring and initializing instance variables.
    • Define a function “makeList()”.
      • Extract the digits.
      • Append the digit.
      • Divide the value of “num” by “base”.
      • If the condition “self.num < self.base” is true
        • Set the value of “digit”.
        • Set the value of “num” as 0.
        • Append the value of “digit”.
          • If the condition is not true.
          • Call the function “makeList()”.
    • Define a function “getDigits(self)”.
      • Call a function “reverse()”.
      • Define the array of digit strings.
      • Define an array “newlist”.
      • Iterate a “for” loop.
        • Set the value of “num” with array values.
        • Append the value of num.
        • Creating a string “str1”.
  • Call the function “BaseConversion()”.
  • Call the function “getDigits()”.
  • Printing the list.

Blurred answer
Students have asked these similar questions
What is cloud computing and why do we use it? Give one of your friends with your answer.
What are triggers and how do you invoke them on demand? Give one reference with your answer.
Discuss with appropriate examples the types of relationships in a database. Give one reference with your answer.
Knowledge Booster
Background pattern image
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning