Showing posts with label coding for kids. Show all posts
Showing posts with label coding for kids. 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")

Friday, July 17, 2020

A Tree Planter Python Program [FREE CODE]

*****
This  Short n Sweet Python Program plants a Virtual Tree made up of  English Alphabets. Great Learning for Kids :)
*****

n = int(input("Enter Alphabets Tree Height:"))
if n <=26:
    j = 1
    for x in range(0,n):
        for y in range(n,x,-1):
            print(" ", end="")
        print(chr(x+65) * j, end="")
        j = j+2
        for w in range(n,x,-1):
            print("",end="")
        print()
else:
    print("English Language has only 26 Alphabets. Enter accordingly.")




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 :)")