Professional Documents
Culture Documents
Lesson 1
Lesson 1
LOOPS
d=b*b-4*a*c
if(d < 0):
print("The roots are imaginary")
else:
r1=(-b+math.sqrt(d))/(2*a) #to calculate square root */
r2=(-b-math.sqrt(d))/(2*a)
print("The first roots is: ",r1, "The first roots is: ",r2)
print("The first roots is: ", int(r1), "The first roots is: ", int(r2))
print("The first roots is: ", math.ceil(r1), "The first roots is: ", math.ceil(r2))
print("The first roots is: ", math.floor(r1), "The first roots is: ", math.floor(r2))
import random
from array import*
import numpy as np
from numpy import shape
LOOPS
count=0
count1=0
i=0
m=int(input("Enter number of days for the temperature records: "))
a=array('i',[])
a_new=array('i',[])
for i in range(0, m):
x=int(input(f"Enter the temperature value {i+1}: "))
if x <360:
count=count + 1
if x >530:
count1=count1 + 1
a.append(x)
if x < 360:
x = 360
if x > 530:
x = 530
a_new.append(x)
sum=0
for e in a_new:
sum = sum + e
o = np.reshape(a,(12,6))
p = np.reshape(a_new,(12,6))
f=np.delete(p,(0,1,6),axis=0) #delete row values in the 1st, 2nd and 7th row
g=np.delete(p,(2,4),axis=1) #delete row values in the 3rd and 5th columns
q=np.reshape(f,(54))
q1= np.reshape(q,(9,6))
r=np.reshape(g,(48))
r1= np.reshape(g,(12,4))
sum1=0
for e in q:
sum1 = sum1 + e
sum2=0
for e in r:
sum2 = sum2 + e
print(a)
print("\n",a_new)
print(f"\nThe number temperature data below 460 is: {count} and temperature data below 460 is {count1}")
print("The total temperature is: ",sum)
print("\n",o)
print("\n",p)
print("\n",f)
print("\n",q)
print("\n",r)
print("\n",q1)
print("\n",r1)
print(f"\nThe total sample temperature is: {sum1} for subtracted rows and {sum2} for subtracted columns")
print("\nThe average daily coal usage is: ",sum1/54)
print("\nThe average daily coal usage is: ",sum2/48)
THANK YOU