Python Modules
Python Modules
Aayush
#A program to input three coefficients of a quadratic equation and display the
roots if they are real, otherwise the message that the roots are imaginary.
import math
D = (b**2) - 4 * (a * c)
if D>= 0:
x1 = (-b + math.sqrt(D)) / (2 * a)
x2 = (-b - math.sqrt(D)) / (2 * a)
else:
#A script that generates 2 random numbers between 0-100 and asks the user to
predict their sum. The program displays the total number of correct and wrong
guesses.
import random as rd
right=0
wrong=0
for i in range(10):
x1=rd.randint(0, 100)
x2=rd.randint(0, 100)
sum=x1+x2
if guess==sum:
print('Correct!')
right+=1
else:
wrong+=1
#To create a list of n numbers input by the user and display the mean and the
median.
import statistics as st
l=[]
for i in range(n):
Mean: 1.14
Median: 2.1