This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | |
<html xmlns="http://www.w3.org/1999/xhtml"> | |
<head> | |
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" /> | |
<title>Patch Rowcester</title> | |
</head> | |
<body bgcolor="black" text="#FFFF00"> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def isPalindrome(s): | |
def toChar(s): | |
s = s.lower() | |
ans='' | |
for c in s: | |
if c in 'abcdefghijklmnopqrstuvwxyz1234567890!@#$%^&*()-=_+<>/?;:{}[]': | |
ans = ans+c | |
return ans | |
def isPal(s): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def gcdIter(a,b): | |
x = min(a,b) | |
for i in range(min(a,b)): | |
if a%x==0 and b%x==0: | |
break | |
else: | |
x -= 1 | |
return x | |
print('This is a program to calculate the GCD of two integers.') | |
a = int(raw_input('Enter first number: ')) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def recurPowerNew(base, exp): | |
''' | |
base: int or float. | |
exp: int >= 0 | |
returns: int or float; base^exp | |
''' | |
# Your code here | |
if exp<=0: | |
return 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
balance = float(raw_input('Enter the balance: ')) | |
annualInterestRate = float(raw_input('Enter the annual interest rate (decimal): ')) | |
##defining the variables | |
monthlyInterestRate = annualInterestRate/12.0 | |
##Lowest payment will not be lower than balance/12 | |
low = balance/12.0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
balance = float(raw_input("Enter the total balance: ")) | |
annualInterestRate = float(raw_input("Enter the annual interest rate (decimal): ")) | |
monthlyInterestRate = annualInterestRate/12.0 | |
initialPayment = 0 | |
totalPaid = 0 | |
while True: | |
initialPayment += 10 | |
tempBalance = balance | |
for i in range(1,13): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
balance = float(raw_input("Enter the outstanding balance: ")) | |
annualInterestRate = float(raw_input("Enter annual interesst rate (decimal): ")) | |
monthlyPaymentRate = float(raw_input("Enter monthly payment rate (decimal): ")) | |
monthlyInterestRate = annualInterestRate/12.0 | |
totalPaid = 0 | |
for i in range(1,13): | |
minMonthlyPayment = monthlyPaymentRate * balance | |
print("Month: " + str(i)) | |
print("Minimum monthly payment: " + str(round(minMonthlyPayment,2))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def isVowel(char): | |
''' | |
char: a single letter of any case | |
returns: True if char is a vowel and False otherwise. | |
''' | |
# Your code here | |
if ((char =='a') or (char=='e') or (char == 'i') or (char == 'o') or (char =='u')): | |
return True | |
elif ((char =='A') or (char=='E') or (char == 'I') or (char == 'O') or (char =='U')): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def odd(x): | |
''' | |
x: int or float. | |
returns: True if x is odd, False otherwise | |
''' | |
# Your code here | |
y = x%2 | |
return bool(y) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def clip(lo, x, hi): | |
''' | |
Takes in three numbers and returns a value based on the value of x. | |
Returns: | |
- lo, when x < lo | |
- hi, when x > hi | |
- x, otherwise | |
''' | |
# Your code here | |
return min(max(x,lo),hi) |
NewerOlder