Friday, October 21, 2016

Random Python Programs October 17-21

Program Let's You Set The Parameter to Count To A Certain Number, From A Certain Number
numbera=int(input("Type in the Number you Want to Count From: "))
numberb=int(input("Type in the Number you Want to Count To: "))
numberb+=1for counter in range((numbera),(numberb)):
    print(counter)



Program Let's You Set A Number to Countdown From
counter=int(input("Type in the Number you Want to Count Down From: "))
while counter > 0:
    print(counter)
    counter-=1



Program Let's You Set a Number to Count to, and the Rate of Which to Count to it
numberb=int(input("Type in the Number you Want to Count To: "))
numberb +=1numberc=int(input("Type in the Number That Represents What You Want to Count by: "))
for counter in range(0,(numberb),(numberc)):
    print(counter)



Newton's Squareroot Calculator
import math
def my_sqrt(a):
    x = a
    while True:
        y = (x + a/x) /2        if y == x:
            break        x =y
    return y
a=int(input("Type in the Number you Want to Find the Squareroot Of: "))
print ("Python Version: "+(str(math.sqrt(a)))+"  "+"Newton Version: "+ (str(my_sqrt(a))))



Program Let's You Generate A List of Three Items
lista=(input("List Item One: "))
listb=(input("List Item Two: "))
listc=(input("List Item Three: "))
list = [lista,listb,listc]
print(list)


Program Let's You Turn Any Text String, Into a Vertical List
lista=str(input("What String Do You Want to Turn Into A Vertical List?:   "))
for x in lista:
    print(x)
Program Is a Weird Sum Loop Program
numbera=int(input("Type in the Number you Want to Equal the Running Total: "))
numberb=int(input("Type in the Number you Want for K: "))
numberc=int(input("Type in the Number you Want to Be The Loop Condition to Be Less Than Or Equal To: "))
numberd=int(input("Type in the Number you Want to Use For Sum Increments: "))

total =(numbera)
k = (numberb)
while k <= (numberc):
    total += k
    print("total =", total, "k =", k)
    k += (numberd)
print(total)




Program Calculates Total, When Given a Price, By Applying Tax
subtotal = 0while True:
    print("Enter a price ->", end="")
    response = input()
    if response == "":
        break    else:
        subtotal += float(response)
tax = subtotal * 0.09print("subtotal= ",subtotal,"tax= ",tax,"total= ",subtotal+tax)


Program Let's You Set What You Want to Count to, Count From, and In What Increments
numbera=int(input("Type in the Number you Want to Count From: "))
numberb=int(input("Type in the Number you Want to Count To: "))
numberc=int(input("Type in the Increments You Want to Use: "))
numberb+=1for counter in range((numbera),(numberb), (numberc)):
    print(counter)


Program Allows You To Calculate The Sum of a Range of Numbers
print("This Program Allows You To Calculate The Sum of a Range of Numbers")
numbera=int(input("Type in the Number you Want to Start From: "))
numberb=int(input("Type in the Number you Want to End At: "))
numberc=int(input("Type in the Increments You Want to Use: "))
numberb+=1a=range((numbera),(numberb), (numberc))
print(sum(a))

No comments:

Post a Comment