Answer:
def sum_digits(number):
total = 0
if 1 <= number <= 999:
while number > 0:
r = int (number % 10)
total +=r
number /= 10
else:
return -1
return total
print(sum_digits(658))
Explanation:
Write a function named sum_digits that takes one parameter, number
Check if the number is between 1 and 999. If it is, create a while loop that iterates until number is greater than 0. Get the last digit of the number using mudulo and add it to the total. Then, divide the number by 10 to move to the next digit. This process will continue until the number is equal to 0.
If the number is not in the given range, return -1, indicating invalid range.
Call the function and print the result
Answer:
-6x^4 + 7x^3 + 17x^2 -4x
Explanation:
( f x g )( x )
Substitute
[( -2x^2 + 5x -1 )( 3x + 4 )]( x )
Use the Distributive Property
[-2x^2( 3x) + 5x( 3x) - 1( 3x) -2x^2( 4) + 5x (4) -1 (4)] (x)
Simplify
( -6x^3 + 7x^2 + 17x -4)(x)
Distributive Property
-6x^4 + 7x^3 + 17x^2 -4x
Answer:
num1 = int(input("Enter number 1: "))
num2 = int(input("Enter number 2: "))
choice = input("Do you want to multiply them?: ")
if choice.capitalize() == "Yes":
print(num1 * num2)
else:
print("Peace out.")
Explanation:
Gg ez.
(I wrote the it in python because I don't know what language you want it in. Next time, say what language you want.)