Showing posts with label Free Code. Show all posts
Showing posts with label Free Code. Show all posts

Friday, August 7, 2020

Middle School Mathematics, Understanding Polygons - [FREE CODE]

*****
This program will tell you all about the Angles of the selected Polygon when you enter the ratio of its sides.
***** 

a = input("Enter polygon : ")

if a.lower() == "triangle":

    b = int(input("Enter  ratio of first angle : "))

    c = int(input("Enter ratio of second angle : "))

    d = int(input("Enter ratio of third angle : "))

    e = b + c + d

    f = 180 / e

    g = b * f

    h = c * f

    i = d * f

    print("Angles of the",a,"are",round(g),round(h),"and",round(i))

elif a.lower() == "quadrilateral":

    b = int(input("Enter  ratio of first angle : "))

    c = int(input("Enter  ratio of second angle : "))

    d = int(input("Enter  ratio of third angle : "))

    e = int(input("Enter  ratio of fourth angle : "))

    v = b + c + d + e

    w = 360 / v

    m = b * w

    n = c * w

    o = d * w

    p = e * w

    print("Angles of the",a,"are",round(m),round(n),round(o),"and",round(p))

elif a.lower() == "pentagon":

    b = int(input("Enter  ratio of first angle : "))

    c = int(input("Enter  ratio of second angle : "))

    d = int(input("Enter  ratio of third angle : "))

    e = int(input("Enter  ratio of fourth angle : "))

    f = int(input("Enter  ratio of fifth angle : "))

    v = b + c + d + e + f

    w = 540/ v

    m = b * w

    n = c * w

    o = d * w

    p = e * w

    q = f * w

    print("Angles of the", a, "are", round(m), round(n), round(o),round(p),"and",round(q))

elif a.lower() == "hexagon":

    b = int(input("Enter  ratio of first angle : "))

    c = int(input("Enter  ratio of second angle : "))

    d = int(input("Enter  ratio of third angle : "))

    e = int(input("Enter  ratio of fourth angle: "))

    f = int(input("Enter  ratio of fifth angle : "))

    g = int(input("Enter  ratio of sixth angle : "))

    v = b + c + d + e + f + g

    w = 720 / v

    m = b * w

    n = c * w

    o = d * w

    p = e * w

    q = f * w

    r = g * w

    print("Angles of the", a, "are", round(m), round(n), round(o), round(p),round(q),"and",round(r))

elif a.lower() == "heptagon":

    b = int(input("Enter  ratio of first angle : "))

    c = int(input("Enter  ratio of second angle : "))

    d = int(input("Enter  ratio of third angle : "))

    e = int(input("Enter  ratio of fourth angle : "))

    f = int(input("Enter  ratio of fifth angle : "))

    g = int(input("Enter  ratio of sixth angle : "))

    h = int(input("Enter  ratio of seventh angle : "))

    v = b + c + d + e + f + g + h

    w = 900 / v

    m = b * w

    n = c * w

    o = d * w

    p = e * w

    q = f * w

    r = g * w

    s = h * w

    print("Angles of the", a, "are", round(m), round(n), round(o), round(p), round(q),round(r),"and",round(s))

elif a.lower() == "octagon":

    b = int(input("Enter  ratio of first angle : "))

    c = int(input("Enter  ratio of second angle : "))

    d = int(input("Enter  ratio of third angle : "))

    e = int(input("Enter  ratio of fourth angle : "))

    f = int(input("Enter  ratio of fifth angle : "))

    g = int(input("Enter  ratio of sixth angle : "))

    h = int(input("Enter  ratio of seventh angle : "))

   i = int(input("Enter  ratio of eighth angle : "))



    v = b + c + d + e + f + g + h + i

    w = 1080 / v

    m = b * w

    n = c * w

    o = d * w

    p = e * w

    q = f * w

    r = g * w

    s = h * w

    t = i * w

    print("Angles of the", a, "are", round(m), round(n), round(o), round(p), round(q), round(r),round(s), "and",round(t))

elif a.lower() == "nonagon":

    b = int(input("Enter  ratio of first angle : "))

    c = int(input("Enter  ratio of second angle : "))

    d = int(input("Enter  ratio of third angle : "))

    e = int(input("Enter  ratio of fourth angle : "))

    f = int(input("Enter  ratio of fifth angle : "))

    g = int(input("Enter  ratio of sixth angle : "))

    h = int(input("Enter  ratio of seventh angle : "))

   i = int(input("Enter  ratio of eighth angle : "))

  j= int(input("Enter  ratio of ninth angle : "))



    j = int(input("Enter ninth ratio : "))

    v = b + c + d + e + f + g + h + i + j

    w = 1260/ v

    m = b * w

    n = c * w

    o = d * w

    p = e * w

    q = f * w

    r = g * w

    s = h * w

    t = i * w

    u = j * w

    print("Angles of the", a, "are", round(m), round(n), round(o), round(p), round(q), round(r), round(s),

          round(t),"and",round(u))

elif a.lower() == "decagon":

   b = int(input("Enter  ratio of first angle : "))

    c = int(input("Enter  ratio of second angle : "))

    d = int(input("Enter  ratio of third angle : "))

    e = int(input("Enter  ratio of fourth angle : "))

    f = int(input("Enter  ratio of fifth angle : "))

    g = int(input("Enter  ratio of sixth angle : "))

    h = int(input("Enter  ratio of seventh angle : "))

   i = int(input("Enter  ratio of eighth angle : "))

  j= int(input("Enter  ratio of ninth angle : "))

 k= int(input("Enter  ratio of tenth angle : "))



    v = b + c + d + e + f + g + h + i + j + k

    w = 1440/ v

    m = b * w

    n = c * w

    o = d * w

    p = e * w

    q = f * w

    r = g * w

    s = h * w

    t = i * w

    u = j * w

    l = k * w

    print("Angles of the", a, "are", round(m), round(n), round(o), round(p), round(q), round(r), round(s),

          round(t),round(u),"and",round(l))

else:

    print("Enter Correct Value Please")


Polygon's Exterior Angle Finder - [FREE CODE}

*****
This Middle School Mathematics Program will tell you the exterior angle when you know the sides
*****

 a = int(input("Enter Sides of the Regular Polygon : "))

b = (a - 2) * 180

c = b/a

d = 360 - c

print("Each Exterior Angle's measure of the Polygon is",round(d),"degree")


Wednesday, August 5, 2020

This Middle School Mathematics Program lets you find the type of Polygon when you enter the Exterior Angle of a Polygon-[FREE CODE]

*****
This Middle School Mathematics Program lets you find the type of Polygon when you enter the Exterior Angle of a Polygon
*****



a = int(input("Enter Exterior Angle of the Polygon : "))

if a == 180:

    print("Polygon can not be formed")

elif a == 360:

    print("Polygon can not be formed")

elif 360 % a == 0:

    b = 360 / a

    if b == 3:

        print("There are", round(b), "sides in the polygon and its known as a Triangle")

    elif b == 4:

        print("There are", round(b), "sides in the polygon and its known as a Quadrilateral")

    elif b == 5:

        print("There are", round(b), "sides in the polygon and its known as a Pentagon")

    elif b == 6:

        print("There are", round(b), "sides in the polygon and its known as a Hexagon")

    elif b == 7:

        print("There are", round(b), "sides in the polygon and its known as a Heptagon")

    elif b == 8:

        print("There are", round(b), "sides in the polygon and its known as an Octagon")

    elif b == 9:

        print("There are", round(b), "sides in the polygon and its known as a Nonagon")

    elif b == 10:

        print("There are", round(b), "sides in the polygon and its known as a Decagon")

    else:

        print("There are", round(b), "sides in the polygon")

else:

    print("Polygon cant be formed")


Easy Python Program for School Kids to find the Distance, Speed and Time [ Free Code ]

*****
Distance = Speed * Time , Using this formula anyone of these 3 quantities can be calculated if the other two are given.
*****

n = input("Enter the thing u want to calculate (speed, distance or time) : ")
if n.lower() == "speed":
a = float(input("Enter Distance (in km) : "))
b = float(input("Enter time (in hr) : "))
c = a/b
print("Speed is",c,"km/hrs")
print("Speed is",(a * 1000)/(b * 3600),"m/s")
elif n.lower() == "distance":
a = float(input("Enter speed (in km/hrs[as decimal]) : "))
b = float(input("Enter time (in hrs) : "))
print("Distance is",a * b,"kms")
print("Distance is",(a * b) * 1000,"m")
elif n.lower() == "time":
a = float(input("Enter Distance (in km) : "))
b = float(input("Enter Speed (in km/hr[as decimal]) : "))
print("Time is",a/b,"hrs")
print("Time is",(a/b) * 3600,"sec")
else:
print("brrr")

Saturday, August 1, 2020

Python Program to find the LCM and HCF of Rational Numbers [ Free Code ]

*****
In this Python Program we find the LCM and HCF of two rational numbers such as 2/5 and 5/7.
The Daily code challenge is to implement Exception Handling in the program for a Divide by Zero Error.
The use of fractions Module is done here.
*****
import fractions

def lcm(x, y):
if x > y:
greater = x
else:
greater = y


while (True):
if ((greater % x == 0) and (greater % y == 0)):
lcm = greater
break
greater += 1
return lcm


def hcf(x, y):
if x > y:
smaller = y
else:
smaller = x
for i in range(1, smaller + 1):
if ((x % i == 0) and (y % i == 0)):
hcf = i
return hcf

a= fractions.Fraction(input("Enter 1st Rational no: "))
b= fractions.Fraction(input("Enter 2nd Rational no: "))

c = a.numerator
d = a.denominator
e = b.numerator
f = b.denominator
print("The lcm of",a,"and",b,"is",lcm(c,e),"/",hcf(d,f))
print("The gcd of",a,"and",b,"is",hcf(c,e),"/",lcm(d,f))

Wednesday, July 29, 2020

Simple python Program to let you know which Article( A/An) to append before a word-[FREE CODE]

*****
Simple Python Program to let you know which Article( A/An) to append before a Word. This is a scalable program as it does not contain all the use cases/ special cases where An is used. Feel free to add those cases in the if block and share in the comments section.
*****
a = input("Enter a word : ")
vowels = ['a','e','i','o']
excep = ['ho']
other = ['un','eu']
if a[0] in vowels:
    print("AN will come before the word")
elif a[0] == "h" and a[1] == "o":
    print("AN will come before the word")
elif a[0] == "u" and a[1] == "n":
    print("A will come before the word")
elif a[0] == "u":
    print("An will come before the word")
else:
    print("A will come before the word")

Monday, July 27, 2020

Easy Python Program to count Vowels in a name or sentence.[Free Code]

*****
Vowel Counter
*****
import numpy as np
a = input("Enter a word : ")
b = []
v = len(a)
vowels = ['a','e','i','o','u','A','E','I','O','U']
for i in range(v):
if a[i] in vowels:
b.append(a[i])

x = np.array(b)
if len(b)!= 0:
print("THE VOWELS ARE :", b, len(b)," Vowels Found")
print("Unique Vowels are:",np.unique(x))
elif len(b)==0:
print(len(b), " VOWELS FOUND")
else:
print("Unexpected Error")

Tuesday, July 21, 2020

Leap Year Calculator [FREE CODE]

*****
This Python program tells the user whether the entered year is leap year or not. Seems Simple, But its a bit dicey..Give it a Try!!
*****

while True:

    a = int(input("Enter year : "))
    if a % 100 == 0:
        if a % 400 == 0:
            print("The year is leap")
        else:
            print("Not a leap Year")
    else:
        if a % 4 == 0:

            print("The year is leap")
        else:
            print("No leap")

Sunday, July 19, 2020

Python Program to Calculate Exposure Value from Aperture and Shutter Speed [Free Code]

ev = [[-4,-3,-2,-1,0,1,2,3,4,5,6],[-3,-2,-1,0,1,2,3,4,5,6,7],[-2,-1,0,1,2,3,4,5,6,7,8],[-1,0,1,2,3,4,5,6,7,8,9],[0,1,2,3,4,5,6,7,8,9,10]
,[1,2,3,4,5,6,7,8,9,10,11],[2,3,4,5,6,7,8,9,10,11,12],[3,4,5,6,7,8,9,10,11,12,13],[4,5,6,7,8,9,10,11,12,13,14],[5,6,7,8,9,10,11,12,13,14,15]
,[6,7,8,9,10,11,12,13,14,15,16],[7,8,9,10,11,12,13,14,15,16,17],[8,9,10,11,12,13,14,15,16,17,18],[9,10,11,12,13,14,15,16,17,18,19]
,[10,11,12,13,14,15,16,17,18,19,20],[11,12,13,14,15,16,17,18,19,20,21]]
#for r in ev:
# for c in r:
# print(c,end = " ")
# print()

print("""
Enter Shutter Speed as number specified in the table
15.0 0
8 1
4 2
2 3
1 4
1/2 5
1/4 6
1/8 7
1/15 8
1/30 9
1/60 10
1/125 11
1/250 12
1/500 13
1/1000 14
1/2000 15
""")
s = int(input(": "))


print("""
Enter Aperture as number specified in the table
f1.0 0
f1.4 1
f2 2
f2.8 3
f4 4
f5.6 5
f8 6
f11 7
f16 8
f22 9
f32 10

""")
a = int(input(": "))
uev = ev[s][a]
print("Your Exposure Value is ", uev)
if uev < 0 :
print(" Your Image is likely to be Underexposed")
elif uev > 4 :
print(" Your Image is likely to be Overexposed")
else:
print(" You might just get a good shot")


Friday, July 17, 2020

Python Program for 8th standard Mathematics kids calculates Volume of a 3D object of your choice.[FREE CODE]

*****
This easy and simple Python code for 8th standard Mathematics kids calculates Volume of a 3D object of your choice. Its real fun and learning,Try it out!!
*****

while True:
    a = "cube"
    b = "cuboid"
    c = "cylinder"
    s = "sphere"
    p = "pyramid"
    d = input("""  What do U want to calculate? 
                   Type CUBE for volume of a CUBE
                   Type CUBOID for Volume of CUBOID
                   Type CYLINDER for Volume of CYLINDER
                   Type SPHERE for Volume of SPHERE
                   Type PYRAMID for Volume of  a PYRAMID : """)
    if a.lower() == d.lower():
        e = int(input("Enter edge of cube : "))
        print("*******Volume of cube is",round(e ** 3))
    elif b.lower() == d.lower():
        f = int(input("Enter length  of Cuboid: "))
        g = int(input("Enter base of Cuboid: "))
        h = int(input("Enter height of Cuboid : "))
        print("Volume of Cuboid is",round(f * g * h))
    elif c.lower() == d.lower():
        i = int(input("Enter radius of Cylinder: "))
        j = int(input("Enter height of Cylinder : "))
        print("Volume of Cylinder is",round(22/7 * (i) ** 2 * j))
    elif s.lower() == d.lower():
        k = int(input("Enter radius of Sphere : "))
        print("The Volume of Sphere is",round(4/3 * 22/7 * (k) ** 3))
    elif p.lower() == d.lower():
        l = int(input("Enter length of Pyramid : "))
        m = int(input("Enter width of Pyramid : "))
        n = int(input("Enter height of Pyramid : "))
        print("Volume of Pyramid is",round((l * m * n)/3))
    else:
        print("Enter Valid Entry.....NERD")


Thursday, July 16, 2020

Easy Python Program for predicting Zodiac Sign [ FREE CODE]

*****
This Python Program will tell you your Zodiac Sign, when you Enter your Date of Birth. Interesting! Isn't it ??!!
*****


while True:
    y = int(input("Enter year: "))
    m = int(input("Enter month: "))
    d = int(input("Enter date: "))
    from datetime import date
    my_date = date(y,m,d)
    if (my_date.month == 12 and my_date.day <= 23) or (my_date.month == 1 and my_date.day <= 19):
        print("Hello CAPRICORN")
    elif (my_date.month == 1 and my_date.day >= 20) or (my_date.month == 2 and my_date.day <= 19):
            print("Hello AQUARIAN")
    elif (my_date.month == 2 and my_date.day >= 20) or (my_date.month == 3 and my_date.day <= 20):
            print("Hello PISCEAN")
    elif (my_date.month == 3 and my_date.day >= 21) or (my_date.month == 4 and my_date.day <= 20):
            print("Hello ARIES")
    elif (my_date.month == 4 and my_date.day >= 21) or (my_date.month == 5 and my_date.day <= 20):
            print("Hello TAURUS")
    elif (my_date.month == 5 and my_date.day >= 21) or (my_date.month == 6 and my_date.day <= 20):
            print("Hello GEMINI")
    elif (my_date.month == 6 and my_date.day >= 21) or (my_date.month == 7 and my_date.day <= 22):
            print("Hello CANCER")
    elif (my_date.month == 7  and my_date.day >= 23) or (my_date.month == 8 and my_date.day <= 22):
            print("Hello LEO")
    elif (my_date.month == 8 and my_date.day >= 23) or (my_date.month == 9 and my_date.day <= 22):
            print("Hello VIRGO")
    elif (my_date.month == 9 and my_date.day >= 23) or (my_date.month == 10 and my_date.day <= 22):
            print("Hello LIBRA")
    elif (my_date.month == 10 and my_date.day >= 23) or (my_date.month == 11 and my_date.day <= 22):
            print("Hello SCORPIO")
    elif (my_date.month == 11 and my_date.day >= 23) or (my_date.month == 12 and my_date.day <= 21):
            print("Hello SAGITARIUS")
    else:
        print("Please Enter valid Date of Birth :)")