Skip to content

Commit 4059439

Browse files
committed
Number related problem added
1 parent faeb815 commit 4059439

File tree

6 files changed

+153
-12
lines changed

6 files changed

+153
-12
lines changed

Number-Related/Average-of-numbers.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Want to try it yourself first? Go to the code editor and try it.
2323
</details>
2424
<br>
2525

26-
**[Try It:](/#)**
26+
**[Try It:](/https://play.google.com/store/apps/details?id=com.learnprogramming.codecamp)**
2727

2828

2929
#### S-3: Solution
@@ -74,7 +74,7 @@ In the second approach, other than directly adding to the list, we are adding it
7474
> To get the average, calculate the total and divide by the number of elements.
7575
7676
&nbsp;
77-
[![Next Page](../assets/next-button.png)](../README.md)
77+
[![Next Page](../assets/next-button.png)](Divisible-by-3-and-5.md)
7878
&nbsp;
7979

8080
###### tags: `programmig-hero` `python` `float` `int` `math`

Number-Related/Coin-sum.md

Whitespace-only changes.
+69
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
2+
## 2.4: Divisible by 3 and 5
3+
4+
**S-1: The problem**
5+
For a given number, find all the numbers smaller than the number. Numbers should be divisible by 3 and also by 5.
6+
7+
<details>
8+
<summary><b>S-2: Click Here For Show Hints</b></summary>
9+
<p>So, you have to check two conditions: make sure the number is divisible by 3, and also by 5.
10+
11+
> Hence, you will need to use two conditions.
12+
</p>
13+
</details>
14+
<br>
15+
16+
**[Try It:](/https://play.google.com/store/apps/details?id=com.learnprogramming.codecamp)**
17+
18+
#### S-3: Solution
19+
```python
20+
def divisible_by_3and5(num):
21+
result = [ ]
22+
for i in range(num):
23+
if i%3 == 0 and i%5 == 0:
24+
result.append(i)
25+
return result
26+
27+
num = int (input('Enter your number: '))
28+
result = divisible_by_3and5(num)
29+
print(result)
30+
```
31+
32+
**[Try It:](/https://play.google.com/store/apps/details?id=com.learnprogramming.codecamp)**
33+
34+
#### S-4: Explanation
35+
This one is easy. We took an input number from the user, and then pass it to a function.
36+
37+
In the function, we have a list and we ran a loop. This loop runs a range. This means we will get numbers from 0 to num. Here, num is the number that the user entered.
38+
39+
Inside the loop, we have an if block. In the if block, we have two conditions. One condition says i % 3 ==0
40+
41+
This means if you divide i by 3 and there will not be any remainder. If there is no remainder then the number is divisible by 3.
42+
43+
Similarly, i%5==0 means the number is divisible by 5.
44+
45+
As we have and between both conditions, to go, insider, the if-block, the i has to be divisible by 3 and also has to be divisible by 5.
46+
47+
Inside the if block, we are appending the number in the result list. And then return the list.
48+
49+
That’s how we are getting every number divisible by 3 and 5.
50+
51+
> Isn’t it simple and cool?
52+
53+
#### S-5: Quiz
54+
If you want to get the numbers that are either divisible by 3 or divisible by 7, which condition will you use?
55+
56+
1. n%3 == 0 or n%7 ==0
57+
2. n%3 == 0 and n%7 ==0
58+
3. n%3 == 0 || n%7 ==0
59+
60+
**The answer is: 1**
61+
62+
#### S-6: Take Away
63+
Remainder(%) will be 0, if the number gets divided.
64+
65+
&nbsp;
66+
[![Next Page](../assets/next-button.png)](Sum-of-digits.md)
67+
&nbsp;
68+
69+
###### tags: `programmig-hero` `python` `float` `int` `math`

Number-Related/Max-of-three.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ What is the easiest way to find out the largest number?
7171
Use the max function to get the largest number.
7272

7373
&nbsp;
74-
[![Next Page](../assets/next-button.png)](Max-of-three.md)
74+
[![Next Page](../assets/next-button.png)](Average-of-numbers.md)
7575
&nbsp;
7676

7777
###### tags: `programmig-hero` `python` `float` `int` `math`

Number-Related/Sum-of-digits.md

+69
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
2+
## 3.1: Sum of Elements
3+
4+
**S-1: The problem**
5+
For a given list, get the sum of each number in the list
6+
7+
<details>
8+
<summary><b>S-2: Click Here For Show Hints</b></summary>
9+
<p>Should be simple for you. Declare a sum variable. Then just loop through the list and add it to the sum.
10+
</p>
11+
</details>
12+
<br>
13+
14+
#### S-3: Solution
15+
```python
16+
def get_sum(nums):
17+
sum = 0
18+
for num in nums:
19+
sum = sum + num
20+
return sum
21+
22+
23+
nums = [13,89,65,42,12,11,56]
24+
25+
total = get_sum(nums)
26+
print("The total of each elements:",total)
27+
```
28+
**[Try It:](/https://play.google.com/store/apps/details?id=com.learnprogramming.codecamp)**
29+
30+
#### S-4: Explanation
31+
It’s super simple.
32+
33+
You got a list. Loop through the list. You have done that multiple times while learning Fundamentals.
34+
35+
Declare a variable named sum before the loop. And inside the loop, add the number to the sum variable.
36+
37+
And then finally return the sum.
38+
39+
That’s it.
40+
Super easy. Even your grandma can do it.
41+
42+
#### S-5: Shortcut
43+
There is an easier way to get sum of all numbers in a list. You can just pass the list of numbers to the sum function.
44+
45+
```python
46+
nums = [13, 11, 16, 78, 31, 128]
47+
48+
total = sum(nums)
49+
print(total)
50+
```
51+
52+
#### S-6: Quiz
53+
What is the shortcut way to sum all the numbers in a list?
54+
55+
1. Loop through the items
56+
2. Use the sum function
57+
3. Use a calculator
58+
59+
60+
**The answer is: 2**
61+
62+
#### S-7: Take Away
63+
Use the sum function to sum all the numbers in a list.
64+
65+
&nbsp;
66+
[![Next Page](../assets/next-button.png)](../README.md)
67+
&nbsp;
68+
69+
###### tags: `programmig-hero` `python` `float` `int` `math`

README.md

+12-9
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33

44
## 2. Page Outline
55

6-
* **[0](Easy-ones/Math-Power.md "Introduction")** - &nbsp;&nbsp; **[Introduction](/Easy-ones/Math-Power.md)**
6+
* **[0](Easy-ones/Math-Power.md "Introduction")** - &nbsp; **[Introduction](/Easy-ones/Math-Power.md)**
77

8-
* **[1](# "Easy ones")** - &nbsp;&nbsp; **[Easy ones](/Easy-ones/User-input-to-Number.md)**
8+
* **[1](# "Easy ones")** - &nbsp; **[Easy ones](/Easy-ones/User-input-to-Number.md)**
99

1010
* **[1.1](Easy-ones/User-input-to-Number.md "Convert input")** - **[Convert input](/Easy-ones/User-input-to-Number.md)**
1111

@@ -16,30 +16,33 @@
1616
* **[1.4](/Easy-ones/Floor-Division.md "Floor Division")** - **[Floor Division](/Easy-ones/Floor-Division.md)**
1717

1818
* **[1.5](Easy-ones/Temporary-variable.md "Temporary variable")** - **[Temporary variable](/Easy-ones/Temporary-variable.md)**
19+
1920
&nbsp;
2021

21-
* **[2](Number-Relate/Number-Related.md "Number Related")** - &nbsp;&nbsp; **[Number Related](/Easy-ones/Number-Related.md)**
22+
* **[2](Number-Relate/Number-Related.md "Number Related")** - &nbsp; **[Number Related](/Easy-ones/Number-Related.md)**
2223

2324
* **[2.1](Number-Relate "Max of two")** - **[Max of two](/Number-Relate)**
2425

2526
* **[2.2](Easy-ones/Math-Power.md "Max of three")** - **[Max of three](/Easy-ones/User-input-to-Number.md)**
2627

2728
* **[2.3](Easy-ones/Math-Power.md "Average of numbers")** - **[Average of numbers](/Easy-ones/Math-Power.md)**
2829

29-
* **[2.4](# "Divisible by 3 and 5")** - **[Divisible by 3 and 5](/#)**
30+
* **[2.4](Divisible-by-3-and-5.md "Divisible by 3 and 5")** - **[Divisible by 3 and 5](/Divisible-by-3-and-5.md)**
3031

31-
* **[2.5](# "Sum of digits")** - **[Sum of digits](/#)**
32+
* **[2.5](Sum-of-digits.md "Sum of digits")** - **[Sum of digits](/Sum-of-digits.md)**
3233

33-
* **[2.6](# "Coin sum")** - **[Coin sum](/#)**
34+
* **[2.6](Coin-sum.md "Coin sum")** - **[Coin sum](/Coin-sum.md)**
3435

3536
## 0: Introduction
3637

3738
### S-1: Welcome
3839
Welcome to the problem-solving galaxy.
3940

4041
#### S-2: Problem Solving
42+
In this galaxy, we will focus on real-world coding related problem-solving.
43+
44+
The problem-solving means, we will take a small programming problem. We will think about the process of solving the problem and then we will solve it.
4145

42-
> n this galaxy, we will focus on real-world coding related problem-solving.<br><br>The problem-solving means, we will take a small programming problem. We will think about the process of solving the problem and then we will solve it.
4346

4447
#### S-3: Explanation
4548
After the solution, we will explain the answer. Convey the concept and strategy to solve it.
@@ -48,7 +51,7 @@ After the solution, we will explain the answer. Convey the concept and strategy
4851
Solving coding problems helps you to think about the problem. It will make you a better developer. Moreover, if you want to participate in a programming contest, you need to practice problem-solving.
4952

5053
#### S-5: Interview
51-
> Besides, large companies like Google, Facebook, Amazon, Uber, etc. ask a lot of problem-solving related questions in their job interview.<br><br>If you want to work any of these large companies, you should practice problem-solving.
54+
Besides, large companies like Google, Facebook, Amazon, Uber, etc. ask a lot of problem-solving related questions in their job interview.<br><br>If you want to work any of these large companies, you should practice problem-solving.
5255

5356

5457
#### S-6: Many solutions
@@ -57,7 +60,7 @@ Here we are focusing on the thinking and strategies to solve a problem. However,
5760
Always keep an open mind to learn multiple solutions to solve a problem.
5861

5962
#### S-7: Let’s Start
60-
Let’s start your journey. Let’s solve every problem you face.
63+
> Let’s start your journey. Let’s solve every problem you face.
6164
6265
*Let’s do it.*
6366

0 commit comments

Comments
 (0)