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

Python Lab 5

Uploaded by

zaidmubin2002
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views

Python Lab 5

Uploaded by

zaidmubin2002
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

#MUHAMMAD ZAID

#CN-23032
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::Labsession5:::::::::::::::::::::::::::::::::::
# question 1
i=2
x = int(input("Please enter any digit upto which prime numbers are reqd:"))
while i<=x:
if i == 2 or i == 3 or i == 5:
print(i)
if i % 2 and i % 3 and i % 5:
print(i)
i = i+1
x = int(input("Please enter any digit upto which prime numbers are reqd:"))
while i<=x:
if i == 2 or i == 3 or i == 5:
print(i)
if i % 2 and i % 3 and i % 5:
print(i)
i = i+1

# question 2
# Compute the following using FOR LOOP only :

positive= 0
negative= 0
print("Enter numbers of values to be checked")
n = int(input("Please enter any number to check:"))
for i in range (0,n+1):
x=float(input("Please enter any number"))
if x>0:
positive=positive+1
if x<0:
negative=negative+1
print("Total positive number entered:",positive)
print("Total negative number entered:",negative)
# question 6
#To calculate average and percentage marks, you have to ask user to enter marks obtain in 5 subjects
then calculate and print average and percentage marks.

print("Please enter your obtained marks(starting from 1 till 5):")


Total_Marks = int(input("Please enter your Total marks in each subject"))
marks=0
for i in range (1,6):
x = float(input("Please enter the marks of subject: "))
marks = marks+x
percentage = marks*100/(Total_Marks*5)
average = marks/5
print("Percentage obtained is :",percentage ,"%")
print("Average score of 5 subjects is :", average)

#question 5
#write a o ton sum the square of multipls of 4 upto N.
n = int(input("Please enter any number: "))
summatin = 0
for i in range(0, n):
summatin=summatin+(i**2)
i = i+4
print("The sum of square of multiple of 4 till Nth term is:" , summatin)
#question 7

import matplotlib.pyplot as plt

x=0
SFD = []
BMD = []
span = []

UDL = int(input("enter value of load in kip/ft:"))


L = int(input("length of beam:"))
Ra = (UDL * L)/2
Rb = (UDL * L)/2
print("reaction at support A is:",Ra)
print("reaction at support A is:",Ra)
for i in range (0,L+1):
sf=Ra - (UDL*x)
bm= (UDL * x)*(L - x)/2
x = x+1
SFD.append(sf)
BMD.append(bm)
span.append(x)
x=x+1
print("value of span inrerval are:",span)
print("value of SFD are:",SFD)
print("value of BMD are:",BMD)
plt.plot(span,SFD,BMD)
plt.show()

You might also like