Python - Project-2 Term 2
Python - Project-2 Term 2
total=a+b+c
avg=total/3
3. Create a list in Python Perform the following tasks on the list in sequence-
Print the whole list, Delete, Add the name at the end, Remove the item which is at the second
position.
print(names)
del names[1]
1|Page
print(names)
names.remove("John")
print(names)
names.append("Doe")
print(names)
names.insert(2, "Diya")
print(names)
A. Python Program to Print Odd Numbers from 1 to N using For Loop – This Python
program allows the user to enter the maximum limit value. Next, Python is going to
print odd numbers from 1 to the user entered a maximum limit value. In this example,
Python for Loopmakes sure that the odd numbers are between 1 and maximum limit
value.
if(number % 2 != 0):
2|Page
print("{0}".format(number))
B. Python Program to Print Odd Numbers using While Loop - In this python odd numbers
program, we just replaced the For Loop with While Loop.
number = 1
if(number % 2 != 0):
print("{0}".format(number))
number = number + 1
total = 0
# creating a list
# printing total value print("Sum of all elements in given list: ", total)
3|Page
6. Input a number and check if the number is positive, negative or zero and display an
appropriate message
if num > 0:
print("Positive number")
elif num == 0:
print("Zero")
else:
print("Negative number")
p = int(input())
r = float(input())
t = float(input())
si = (p*r*t)/100
print(si)
4|Page
8. To calculate Surface Area and Volume of a Cuboid
length = float(input(’Please Enter the Length of a Cuboid: ’))
5|Page