Code:
def sumfun():
n=-4
sum=0
while(n!=-10):
sum=sum+n
n=n-1
print("The sum is :" ,sum)
sumfun()
Indentation for better understanding:
Output:
Using while loop write a python function to find the sum of the negative numbers -3...
Please write a java program that inputs positive numbers using a while loop until a negative number is input and finds the sum of the numbers input
****python**** Q1. Write a recursive function that returns the sum of all numbers up to and including the given value. This function has to be recursive; you may not use loops! For example: Test Result print('%d : %d' % (5, sum_up_to(5))) 5 : 15 Q2, Write a recursive function that counts the number of odd integers in a given list. This function has to be recursive; you may not use loops! For example: Test Result print('%s : %d' % ([2,...
Python Print integer numbers up to 100 (1, 2, 3, …..) using a while loop. Each integer number takes a separate line.
Using basic c++ 2. Count the positive and negative numbers using ***while loop*** • Write a program that reads unspecified number of integers , determines how many negative and positive values have been read. Also calculate total and average. Your program will end with input 0. • Output Enter an integer, the input ends if it is 0: 25 34 -89 72 -35 -67 21 48 0 The number of positives is 5 The number of negatives is 3 The...
Write a python program that uses a while loop to print numbers 100,98,96... all the way to 0. each number should be printed on a seperate line
Use a loop to find the sum of all numbers between 0 and #mystery_int, including bounds (meaning that if #mystery_int = 7, you add 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7). However, there's a twist: mystery_int might be negative. #So, if mystery_int was -4, you would -4 + -3 + -2 + -1 + 0. Coding Problem 3.3.3 (External resource) 3.0 points possible) SumLoop.py 1 mystery_int -3 loop to find the sum...
1) Translate the following equation into a Python assignment statement 2) Write Python code that prints PLUS, MINUS, O ZERO, depending on the value stored in a variable named N. 3) What is printed by: 3 - 1 while 5: while 10 Print ) Page 1 of 9 4) Write a Python while loop that reads in integers until the user enters a negative number, then prints the sum of the numbers. 1-2 of 9 4) Write a Python while...
Using python, Write a while loop that counts from 1 to 20 by 4s.
Write a recursive function in Python to find the sum of digits of a number. Name the function sum_of_digits. The function should use recursive algorithm (calling itself). The function should print out the sum of all the digits of a given number. For example, sum_of_digits(343) should have a output of 10. Marks will be deducted if you do not follow strictly to the instructions. [3]: N 1 def sum_of_digits(n): HNM in sum_of_digits (343) Out[3]: 10
use python: Write a program that reads in X whole numbers and outputs (1) the sum of all positive numbers, (2) the sum of all negative numbers, and (3) the sum of all positive and negative numbers. The user can enter the X numbers in any different order every time, and can repeat the program if desired. Sample Run How many numbers would you like to enter? 4 Please enter number 1: 3 Please enter number 2: -4 Please enter...