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
Write the SQL code that permits to implement the tables: Student and Transcript. NB: Add the constraints on the attributes – keys and other.
Draw an ERD that will involve the entity types: Professor, Student, Department and Course. Be sure to add relationship types, key attributes, attributes and multiplicity on the ERD.
Draw an ERD that represents a book in a library system. Be sure to add relationship types, key attributes, attributes and multiplicity on the ERD.
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
Text book image
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
Text book image
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
Text book image
COMPREHENSIVE MICROSOFT OFFICE 365 EXCE
Computer Science
ISBN:9780357392676
Author:FREUND, Steven
Publisher:CENGAGE L
Text book image
Systems Architecture
Computer Science
ISBN:9781305080195
Author:Stephen D. Burd
Publisher:Cengage Learning
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT