Skip to content

Commit ee9c6e4

Browse files
authoredAug 8, 2016
Create README.md
0 parents  commit ee9c6e4

File tree

1 file changed

+60
-0
lines changed

1 file changed

+60
-0
lines changed
 

‎README.md

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# Assignment-1
2+
3+
## Notes
4+
5+
Python input() returns the string you've typed on Keyboard
6+
7+
```
8+
name = input("What's your name? ")
9+
```
10+
11+
User Types : John
12+
13+
14+
Now, name becomes equal to "John"
15+
16+
```
17+
a = input("Enter value of a ?") # Suppose user types 2
18+
b = input("Enter value of b ?") # Supoose user types 3
19+
20+
sum = a + b # Sum will be "23" and not 5 because input function returns String
21+
```
22+
23+
So we use something called typecasting to convert one data type into other.
24+
25+
```
26+
a = input("Enter value of a ?") # Suppose user types 2, a is now a string "2"
27+
b = input("Enter value of b ?") # Supoose user types 3, b is now a string "3"
28+
29+
a = int(a) # int() converts string to int
30+
b = int(b)
31+
32+
sum = a + b # Sum will be 5
33+
34+
#You can also do
35+
36+
a = float(a) # a becomes 2.0
37+
b = float(b) # b becomes 3.0
38+
39+
```
40+
41+
## Questions
42+
43+
The formula for computing the final amount if one is earning compound interest is given on Wikipedia as
44+
45+
```
46+
A = P * ( (1 + r/n) ^ (n*t))
47+
48+
49+
^ Power is calculated using ** in Python, 5 ** 2 = 25
50+
51+
P is the principal sum
52+
r is the nominal interest rate
53+
n is the compounding frequency
54+
t is the overall length of time the interest is applied (usually expressed in years).
55+
```
56+
1. Write a Python program that assigns the principal amount of 10000 to variable P, assign to n the value 12, and assign to r the interest rate of 8% (0.08). Then have the program prompt the user (take input from the user) for the number of years, t, that the money will be compounded for. Calculate and print the final amount after t years.
57+
58+
2. Write a program that will compute the area of a rectangle. Prompt the user to enter the width and height of the rectangle. Print a nice message with the answer.
59+
60+
3. Write a program with a function that will convert degrees celsius to degrees fahrenheit and takes degree celsius as a parameter and returns the fahreinheit value.

0 commit comments

Comments
 (0)