**[Try it on Programming Hero](https://play.google.com/store/apps/details?id=com.learnprogramming.codecamp)**
28
28
29
-
### S-4: Explanation
29
+
### Explanation
30
30
Read the code. I think you don’t need any extra explanation here.
31
31
32
32
Original file line number
Diff line number
Diff line change
@@ -1,10 +1,10 @@
1
-
## 6.5 Triangle Area
1
+
## Triangle Area
2
2
---
3
3
4
-
### S-1: The Problem
4
+
### The Problem
5
5
Take three sides of a triangle. And then calculate the area of the triangle.
6
6
7
-
### S-2: How it works
7
+
### How it works
8
8
To calculate the area of the triangle. First, calculate the half of the perimeter. Here perimeter is the sum of each side of the triangle.
9
9
10
10
Let’s call it s.
@@ -16,7 +16,7 @@ s = (a+b+c)/2
16
16
area = √(s(s-a)*(s-b)*(s-c))
17
17
```
18
18
19
-
### S-3: the code
19
+
### the code
20
20
```python
21
21
import math
22
22
@@ -33,7 +33,7 @@ print('Area of your triangle is ', area)
33
33
```
34
34
**[Try it on Programming Hero](https://play.google.com/store/apps/details?id=com.learnprogramming.codecamp)**
35
35
36
-
### S-4: Explanation
36
+
### Explanation
37
37
To calculate the square root. We used the math module. And call math.sqrt.
38
38
39
39
```python
@@ -47,16 +47,19 @@ Similarly, math.sqrt(25) will give 5 as output.
47
47
48
48
This is something new you have learned this time.
49
49
50
-
### S-5: Quiz
50
+
### Quiz
51
51
52
-
1.How would you calculate the square root of a number.
53
-
2. Use math.square.root
54
-
3. Use math.sqroot
55
-
4. Use math.sqrt
52
+
How would you calculate the square root of a number.
53
+
1. Use math.square.root
54
+
2. Use math.sqroot
55
+
3. Use math.sqrt
56
56
57
-
**The answer is: 3**
57
+
<details>
58
+
<summary><b>Show Answer</b></summary>
59
+
<p>The answer is: 3</p>
60
+
</details>
58
61
59
-
### S-6: Take Away
62
+
### Take Away
60
63
The math module has a lot of math-related functionalities.
61
64
62
65
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
## 4.2 Celsius to Fahrenheit
2
2
3
-
### S-1: The problem
3
+
### The problem
4
4
Take the temperature in degrees Celsius and convert it to Fahrenheit.
5
5
6
6
<details>
@@ -12,7 +12,7 @@ Take the temperature in degrees Celsius and convert it to Fahrenheit.
12
12
13
13
Think for a second...How will you multiply a variable by 9 and then divide by 5? and then add 32. Can you do it without looking at the solution?
14
14
15
-
### S-3: The solution
15
+
### The solution
16
16
```python
17
17
celsius =float(input("Enter temperature in degrees Celsius: "))
18
18
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
## 4.4: Decimal to Binary (recursive)
2
2
3
-
### S-1: The Problem
3
+
### The Problem
4
4
Convert a decimal number to binary number using a recursive function.
5
5
<details>
6
6
<summary><b>S-3: Click Here For Show Hints</b></summary>
@@ -9,7 +9,7 @@ Convert a decimal number to binary number using a recursive function.
9
9
So, don’t worry if you felt confused. You are not alone. I am in the same condition as well.</p>
10
10
</details>
11
11
12
-
### S-3: Recursive
12
+
### Recursive
13
13
14
14
```python=
15
15
def dec_to_binary(n):
@@ -27,7 +27,7 @@ print(" ")
27
27
28
28
**[Try it on Programming Hero](https://play.google.com/store/apps/details?id=com.learnprogramming.codecamp)**
29
29
30
-
### S-4: Explanation
30
+
### Explanation
31
31
The core part of the logic is simple. If the number is greater than 1, call the dec_to_binary function again. And, while calling, send the result of dividing operation as the input number.
32
32
33
33
If you remember, the while loop in the previous code problem is similar. In the while loop, we were going back to the next iteration with n = n//2
@@ -40,7 +40,7 @@ While printing, we have one extra thing called end=''.
40
40
The purpose of end='' is to print the output in the same line. If you don’t add end='', every print output will be displayed in a new line.
41
41
42
42
43
-
### S-6: Take Away
43
+
### Take Away
44
44
There are multiple ways to format the print string. Google it, when needed.
45
45
46
46
Original file line number
Diff line number
Diff line change
@@ -1,9 +1,9 @@
1
1
## 4.4: Decimal to Binary
2
2
3
-
### S-1: The Problem
3
+
### The Problem
4
4
Convert a decimal number to binary number.
5
5
6
-
### S-2: Decimal vs Binary
6
+
### Decimal vs Binary
7
7
8
8
The numbers that we use every day is called decimal number. A decimal number could have any of the 10 digits (0, 1, 2, 3, 4,5 6, 7, 8, 9).
9
9
@@ -34,7 +34,7 @@ Then you will reverse the list.
34
34
Finally, you have to put the binary bits (0 and 1) in one number to get the final binary. </p>
35
35
</details>
36
36
37
-
### S-4: Solution
37
+
### Solution
38
38
I looked into the below code 7 times to understand. Still trying to figure it out...So, spend some time here to look at the code:
**[Try it on Programming Hero](https://play.google.com/store/apps/details?id=com.learnprogramming.codecamp)**
60
60
61
-
### S-5: Explanation
61
+
### Explanation
62
62
You have seen the remainder and dividing the number with // before. That is the core part of this decimal to a binary algorithm.
63
63
64
64
So, this part should be easier for you:
@@ -89,16 +89,19 @@ Try to read this explanation and code multiple times. And, if needed, come back
89
89
If you keep trying and revisiting , again and again, these will start making sense.
90
90
91
91
92
-
### S-6: Quiz
92
+
### Quiz
93
93
94
94
1. What is a binary number?
95
95
2. Numbers written on a trash bin
96
96
3. Numbers that use 0,1 only
97
97
4. Numbers with any 2 digits
98
98
99
-
#### The answer is : 2
99
+
<details>
100
+
<summary><b>Show Answer</b></summary>
101
+
<p>The answer is : 2</p>
102
+
</details>
100
103
101
-
### S-7: Take Away
104
+
### Take Away
102
105
Binary numbers use 0 and 1 only.
103
106
104
107
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
## 4.1: Miles to Kilometers
2
2
3
-
#### S-1: The Problem
3
+
#### The Problem
4
4
Convert miles to kilometers.
5
5
6
6
<details>
@@ -12,7 +12,7 @@ Convert miles to kilometers.
12
12
Now, think what you can do with this information. </p>
13
13
</details>
14
14
15
-
### S-3: The solution
15
+
### The solution
16
16
17
17
```python
18
18
miles =float(input("Enter distance in miles: "))
@@ -22,7 +22,7 @@ print("Distance in Kilometers:", kilometers)
22
22
23
23
**[Try it on Programming Hero](https://play.google.com/store/apps/details?id=com.learnprogramming.codecamp)**
24
24
25
-
### S-4: Explanation
25
+
### Explanation
26
26
Just take a number from the user. Allow the user to enter a float number. Then, multiply that number by 1.609344. Keep the multiplication in the kilometers variable.
0 commit comments