def compound_interest(principle, rate, time):
Amount = principle * (pow((1 + rate / 100), time))
CI = Amount - principle
print("Compound interest is", CI)
compound_interest(10000, 10.25, 5)
Solve Problems by Coding Solutions - A Complete solution for python programming
def compound_interest(principle, rate, time):
Amount = principle * (pow((1 + rate / 100), time))
CI = Amount - principle
print("Compound interest is", CI)
compound_interest(10000, 10.25, 5)
from tkinter import *
root = Tk()
root.geometry("300x300")
root.title(" Q&A ")
def Take_input():
INPUT = inputtxt.get("1.0", "end-1c")
print(INPUT)
if(INPUT == "120"):
Output.insert(END, 'Correct')
else:
Output.insert(END, "Wrong answer")
l = Label(text = "What is 24 * 5 ? ")
inputtxt = Text(root, height = 10,
width = 25,
bg = "light yellow")
Output = Text(root, height = 5,
width = 25,
bg = "light cyan")
Display = Button(root, height = 2,
width = 20,
text ="Show",
command = lambda:Take_input())
l.pack()
inputtxt.pack()
Display.pack()
Output.pack()
mainloop()
def Pattern(line):
pat=""
for i in range(0,line):
for j in range(0,line):
if ((j == 1 and i != 0 and i != line-1) or ((i == 0 or
i == line-1) and j > 1 and j < line-2) or (i == ((line-1)/2)
and j > line-5 and j < line-1) or (j == line-2 and
i != 0 and i != line-1 and i >=((line-1)/2))):
pat=pat+"#"
else:
pat=pat+" "
pat=pat+"\n"
return pat
line = 7
print(Pattern(line))
def oddEvenSort(arr, n):
isSorted = 0
while isSorted == 0:
isSorted = 1
temp = 0
for i in range(1, n-1, 2):
if arr[i] > arr[i+1]:
arr[i], arr[i+1] = arr[i+1], arr[i]
isSorted = 0
for i in range(0, n-1, 2):
if arr[i] > arr[i+1]:
arr[i], arr[i+1] = arr[i+1], arr[i]
isSorted = 0
return
arr = [34, 2, 10, -9]
n = len(arr)
oddEvenSort(arr, n);
for i in range(0, n):
print(arr[i], end =" ")
import math
def sumofFactors(n) :
if (n % 2 != 0) :
return 0
res = 1
for i in range(2, (int)(math.sqrt(n)) + 1) :
count = 0
curr_sum = 1
curr_term = 1
while (n % i == 0) :
count= count + 1
n = n // i
if (i == 2 and count == 1) :
curr_sum = 0
curr_term = curr_term * i
curr_sum = curr_sum + curr_term
res = res * curr_sum
if (n >= 2) :
res = res * (1 + n)
return res
n = 18
print(sumofFactors(n))