0% found this document useful (0 votes)
2 views

Shubham Raj Python Practical

The document contains Python practical exercises by Raj Shubham Manoj Kumar, including a program to find the sum of all numbers in a list and another to calculate the sum of all numbers from 1 to a given number. Each exercise includes the code implementation and the expected output. The document serves as a demonstration of basic Python programming skills.

Uploaded by

hui85206
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Shubham Raj Python Practical

The document contains Python practical exercises by Raj Shubham Manoj Kumar, including a program to find the sum of all numbers in a list and another to calculate the sum of all numbers from 1 to a given number. Each exercise includes the code implementation and the expected output. The document serves as a demonstration of basic Python programming skills.

Uploaded by

hui85206
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

NAME :RAJ SHUBHAM MANOJ KUMAR

PRN NO: 04422001670


SEAT NO : 3188
SUB : PYTHON PRACTICAL

1. Write a Python program find the sum of all numbers stored in list.

CODE:
def sum_of_numbers(numbers):
total = 0
for num in numbers:
total += num
return total

my_list = [1, 2, 3, 4, 5]
result = sum_of_numbers(my_list)
print("The sum of the numbers in the list is:", result)

2. Write a Python program to calculate the sum of all numbers from 1


to a given number.

CODE:
def calculate_sum(n):
total = 0
for i in range(1, n+1):
total += i
return total

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


result = calculate_sum(number)
print("The sum of numbers from 1 to", number, "is:", result)

You might also like