Singapore University of Social Sciences**We aren't endorsed by this school
Course
ICT 133
Subject
Computer Science
Date
Jan 12, 2025
Pages
2
Uploaded by UltraApe4892
# ## 2.1 Example & Error code# def main():# print("Covert Celsius to Fahrenheit")# c = float(input("Enter a temperature in Celsius: "))# f = 9/5 * c + 32# print(f)### main()# ## 2.2 Elements of Programs - Statements# # Output statement# print()# print("Hello World!")# print(2 + 3)# print("2+3=", 2 + 3)## print("Hello World!", end=" ")# print(2 + 3, end=" ")# print("2+3=", 2 + 3)# # Assignment statement# def main():# # a = 10# y = eval(input("enter: "))# print(y*9)### main()# x = 1# y = 1# x, y = x-1, x+y# print(x, y)# # Define Loops# for i in range(10):# print(i)## Activity 13# def activity13():# print("a")# for i in range(5):# print(i*i)## print("b")# for d in [3, 1, 4, 1, 5]:# print(d, end=" ")## print("c")# for i in range(4):# print("Hello")## print("d")# for i in range(5):# print(i, 2**i)
## activity13()# ## 2.3 Example Program: Future Valuedef main():print("This program calculates future value")print("of an investment for a number of years specified by you")pricipal = int(input("Enter the initial principal: "))apr = float(input("Enter the annual interest rate as a percentage: "))n = int(input("Enter the number of years of investment: "))for i in range(n):pricipal = pricipal * (1 + apr)print("The value in", n, "years is: ", pricipal)main()