1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
marin [14]
3 years ago
10

Write a program to input a number.Find the sum of digits and number of digits

Computers and Technology
2 answers:
BaLLatris [955]3 years ago
8 0

Answer:

<em>#Sum of Digits</em>

a = int(input("Enter a number: "))

sumofdigits = sum(int(dig) for dig in str(number))  

print("Sum of digits: ", sumofdigits)

<em># Number of digits</em>

count = 0  

print ("Total number of digits : ",len(str(abs(a))))

Explanation:

It is pretty self-explanatory however, I will tell it to you anyways. So, the sum of digits iterates to each digit and adds them up. For the number of digits, it uses in-built functions (length, string and absolute)

ki77a [65]3 years ago
7 0

omg a computer program

i love it

okay so i will assume taht you want the program to be in python

here we go

a = int(input("Enter a number ")

b = int(input("Enter another number ")

sum = a + b

def Digits(sum):

count = 0

while sum != 0:

sum //= 0

count += 1

return count

print(f"Sum is {sum} \nnumber of digits are {Digits(sum)}")

You might be interested in
When creating a presentation you should use a blank as a starting point?
Lera25 [3.4K]
A blank presentation is recommended as the starting point when creating a PowerPoint presentation.  PowerPoint <span>lets you change the appearance, layout and content of your presentation at any time. Starting with a blank presentation lets you experiment more easily with the many features this program offers.</span>
6 0
3 years ago
Convert (65.125)10 to octal.
grigory [225]

Answer:

101.1

Explanation:

Keep in mind that octal has 8 numbers

Step 1: Split your number in 2 parts (integer part and decimal part):

  • integer part 65
  • decimal part 0.125

Step 2: Convert the decimal part. For this step you need to multiply your decimal part and 8 (8 correspond the octal base) and get the integer part until you need it:

      0.125 * 8 =  1

So your decimal part correspond to number 1 in octal = (1)8

Step 3: Convert integer part: for this step you need to divide your integer part by 8 until you can and get the remainder

      65 / 8 = 8 remainder 1

        8 / 8 = 1 remainder 0

         1 / 8 = 0 remainder 1

Step 4: join the remainders from bottom to top and get the integer part

            101

Step 5: join the integer part and the decimal part to get the octal convertion

              101.1

5 0
3 years ago
Write a recursive method named binarySearch that accepts a sorted array of integers and an integer target value and uses a recur
djyliett [7]

Answer:

10

-1

Process finished with exit code 0

Explanation: see code bellow

public class BinarySearchRecursive {

   public static int binarySearch(int[] a, int key) {

       return binarySearchRecursiveHelper(a, key, 0, a.length - 1);

   }

   public static int binarySearchRecursiveHelper(int[] arr, int target, int start, int end) {

       if (start > end) {

           return -1;

       }

       int mid = (start + end) / 2;

       if (arr[mid] == target) {

           return mid;

       } else if (target < arr[mid]) {

           return binarySearchRecursiveHelper(arr, target, start, mid - 1);

       } else {

           return binarySearchRecursiveHelper(arr, target, mid + 1, end);

       }

   }

   public static void main(String[] args) {

       int[] a = {-4, 2, 7, 10, 15, 20, 22, 25, 30, 36, 42, 50, 56, 68, 85, 92, 103};

       int index = binarySearch(a, 42);   // 10

       System.out.println(index);

       index = binarySearch(a, 66);   // -1

       System.out.println(index);

   }

}

6 0
3 years ago
Which of the following is an accurate statement? When the LOWER function is used in a SELECT clause, it will automatically store
quester [9]

Answer:

Hi there! The answer is C:

Explanation:

The scope of the LOWER function is limited to the select clause it is being used in. Outside of the select statement, the column will be returned as it is currently present in the database. Using the LOWER function will not automatically store data in lower case letters in the database tables. As an exercise, try creating a simple database table called "Employees" with columns "id" and "name". Then input a row using an insert statement with id as 1 and name as "BLAH". Try using the select statement with LOWER function and then without the LOWER statement.

5 0
2 years ago
Janeal spends her day looking at the stock and bond markets and evaluating how the portfolios of the businesses she serves will
pychu [463]

Answer:

ur answer good sir will be : financial analyst

and a brainliest will be good to thnx

4 0
3 years ago
Other questions:
  • Consider a multiprocessor CPU scheduling policy. There are 2 options: 1) a singlecommon ready queue of jobs; when a CPU becomes
    8·1 answer
  • Which ipv6 router message is sent via multicast with a scope of link-local with the expectation that all local routers will iden
    5·1 answer
  • Hen using presentation software, what do you do when you "compose a slide"?
    5·1 answer
  • Why do most laptops have LCD rather than OLED displays, which are found on mobile devices?
    9·1 answer
  • What is the first priority when building or using vex robots
    10·2 answers
  • You press the F9 key to convert an object to a symbol true or false​
    12·1 answer
  • Consider the following method, which is intended to return the index of the first negative integer in a given array of integers.
    14·1 answer
  • Fifteen years ago, everyone didn't have a cell phone. Anyone developing an app would not have found many users. Today, the exist
    12·1 answer
  • What's the commission payout for auto bill pay if sold with a ga?
    6·1 answer
  • Examine the following output:
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!