Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PYTHON 3!!!! I'm writing a program to tell whether something is divisible by 7 and im getting confused between the string and intergers forms of

PYTHON 3!!!! I'm writing a program to tell whether something is divisible by 7 and im getting confused between the string and intergers forms of my input.

here is the question and below it is the code that I have now

image text in transcribeddef q1d(Interger): number = int(Interger) stepone = (Interger[-1]*2) steptwo = (Interger[0:1]- stepone) step3 = steptwo[-1] * 2 step4 = 7-step3 list = [number, step4] if (number Question 1d: One method to determine if an Integer is a multiple of 7 is to double the last digit and subtract it from the remaining leading truncated Integer. Apply this rule over and over again till you reach a single digit. The original Integer is divisible by 7 if the absolute value of the result is divisible by 7, or if it is zero For example, consider the Integer. 826 6*2=12 82- 1270 The last digit is 6, double this digit: Subtract 12 from the leading Integer, 82 The last digit is 0, double this digit: Subtract 0 from the leading Integer 7 . . The final value is a single digit of 7, therefore the original Integer 826 is divisible by 7. Write a function named qld) that accepts an Integer as a parameter then: Using only String manipulation and Integer subtraction, follow the method described above to determine if the Integer is a multiple of 7. You may not use modulus operator Create a List so that the first element is either True or False depending on whether the parameter Integer was divisible by 7 or not. If the starting parameter is zero (0) or is not an Integer, the function returns [False] . The second element of the List should be the starting parameter (if it is an Integer) . The rest of the List elements will contain the results of subtracting the doubled digits from the remaining leading Integers (see examples below) Once the evaluation process is complete, the qld ) function should return the List Example Input/ Output: >>>qld (0) False] >>> qld ('hello') [False] >>> qld(14) [True, 14, 7 >>>qld (91) [True, 91, 71 >>> qld(154) [True, 154, 7 >>>qld (323) [False, 323, 26, 10, 1] >>>qld (1800) [False, 1800, 180, 18, 15, 9] >>> qld (2499) [True, 2499, 231, 21, 0] Note: The function returns the List - it does not print anything

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Concepts

Authors: David Kroenke, David Auer, Scott Vandenberg, Robert Yoder

8th Edition

013460153X, 978-0134601533

More Books

Students also viewed these Databases questions

Question

What is a verb?

Answered: 1 week ago

Question

Consider some type of redress for the customer, such as a coupon.

Answered: 1 week ago

Question

Demonstrate through language that you are grateful to be informed.

Answered: 1 week ago

Question

Always mention the specifi c problem the customer faced.

Answered: 1 week ago