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
Explain how to implement two stacks in one array A[1..n] in such a way that neither stack overflows unless the total number elem
algol [13]

Answer:

Check explanation

Explanation:

Two stacks can make use of one array by utilizing various stack pointers that begins from different ends of an array. Looking at the array A[1...n], the first stack will drive elements that starts from position 1 as well as to move its' pointer to n.

The Second stack will begin at the n position and motion its' pointer to 1. The best likely divide is to offer each stack a half of an array. whenever any of two stacks transverse the half-point, an overflow can happen but for that overall number of elements, it must be n

5 0
3 years ago
tiny electrical paths to connect everything together is called ? A. graphic card B. audio card C. CPU D. Motherboard
k0ka [10]

Answer:

Option C, or the CPU.

Explanation:

The audio card simply translate code into sound, the graphic card turns code into graphics, CPU runs electric through tons of little electric pathways, and the motherboard is the object of which all of the above are rested on and connects them together.

8 0
2 years ago
study the picture of the simulation and the graph above. based on the information obtained from your study of the simulation and
andreyandreev [35.5K]
This is how you know i’m def gonna fail my university class this year :/
6 0
2 years ago
The purpose of this assignment is to determine a set of test cases knowing only the function’s specifications, reported hereaf
Nesterboy [21]

Answer:

The program is written using PYTHON SCRIPT below;

N=int(input(" Enter number of Rows you want:"))

M=[] # this for storing the matrix

for i in range(N):

l=list(map(int,input("Enter the "+str(i+1)+" Row :").split()))

M.append(l)

print("The 2D Matrix is:\n")

for i in range(N):

print(end="\t")

print(M[i])

W=[] # to store the first non zero elemnt index

T=[] # to store that value is positive or negative

L=len(M[0])

for i in range(N):

for j in range(L):

if (M[i][j]==0):

continue

else:

W.append(j) # If the value is non zero append that postion to position list(W)

if(M[i][j]>0): #For checking it is positive or negative

T.append(+1)

else:

T.append(-1)

break

print()

print("The first Non Zero element List [W] : ",end="")

print(W)

print("Positive or Negative List [T] : ",end="")

print(T)

Explanation:

In order for the program to determine a set of test cases it takes in input of 2D matrix in an N numbet of rows.

It goes ahead to program and find the column index of the first non-zero value for each row in the matrix A, and also determines if that non-zero value is positive or negative. The If - Else conditions are met accordingly in running the program.

5 0
2 years ago
What port number is the web server listening on for the web request?
Veronika [31]
80 for HTTP, 443 for HTTPS
8 0
3 years ago
Other questions:
  • What is basic function of an operating system?
    10·2 answers
  • Only business writing requires an editing stage
    8·1 answer
  • What is virtual reality?
    10·1 answer
  • Choose the word that best completes this sentence. ____________ should cover every part of the worksite.
    10·2 answers
  • ____ is the official web portal for the U.S. government, providing access to all official U.S. government services and informati
    12·1 answer
  • A ______________ is a way of taking a screenshot or a picture of your computer screen. ​
    14·1 answer
  • Command create database in oracle database ::((
    8·1 answer
  • Write a statement to declare a variable x with data type int and initialise with the value 10​
    13·1 answer
  • Put these operating systems in order according to the date they were released. (The first to be released would be
    10·1 answer
  • Aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!