-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSession F2 - Fundamentals of Programming.py
82 lines (65 loc) · 1.85 KB
/
Session F2 - Fundamentals of Programming.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# This line prints Hello World!
print ("Hello, World!")
# Function to calculate simple interest
def SI():
P = 1500000
R = 0.05
T = 5
SimpleInt = P*R*T
print(SimpleInt)
SI()
# Prints a blank line
print()
# Function to calculate the area of a rectangle
# def areaRectangle():
# length = 10
# breadth = 5
# area = length * breadth
# print (area)
# if a == b:
# print(a)
# areaRectangle()
# Python Indentation
ab = 5
bc = 5
if ab == bc:
print("Both numbers are 5")
print("Welcome")
print("bye")
myPhoneNumber = 80 # camelCase
MyPhoneNumber = 80 # PascalCase
my_phone_number = 80 # snake_case
myphonenumber = 1
print (myphonenumber)
my_Name = "Timothy"
print(my_Name)
first_name = "Bob"
school_attended = "Eton"
my_age = 21
last_name = "Simpson"
type(first_name)
# Write a code that finds the simple interest of a sum given the principal as 1500000, rate is 5% and time is 3 years
def Simple_Interest():
p = 1500000
r = 0.05
t = 3
Simple_Int = p*r*t
print(Simple_Int)
Simple_Interest()
# This calculates the simple interest using inputs
def calculate_interest():
principal = float(input("Enter the principal amount: "))
rate = float(input("Enter the rate as a percentage: "))
rate = rate/100
time = int(input("Enter the number of years: "))
interest = principal * rate * time
print (f"You are owed £{interest}")
calculate_interest()
# Sum of three inputted values
def addition():
Cole = float(input("Cole, please enter your amount: £"))
Nicole = float(input("Nicole please enter your amount: £"))
Derek = float(input("Derek please enter your amount: £"))
total = Cole + Nicole + Derek
print (f"You have a total of £{total} between you")
addition()