Skip to content

Commit 914dec0

Browse files
committed
User input to Number
1 parent bbb6ca8 commit 914dec0

File tree

1 file changed

+60
-21
lines changed

1 file changed

+60
-21
lines changed

README.md

+60-21
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,64 @@
11
# 100 Plus Python Coding Problems With Solutions
22
---
33

4-
# Outline
5-
---
4+
### 1.1: User input to Number
5+
6+
**S-1: The problem**
7+
8+
Take two inputs from the user. One will be an integer. The other will be a float number. Then multiply them to display the output.
9+
10+
<details>
11+
<summary><b>S-2: Click Here For Show Hints</b></summary>
12+
<p>Use input. By default, input gives you a string. Then use int and float to convert the input to a number. And then multiply them. <br><br>That’s it.</p>
13+
</details>
14+
<br>
15+
16+
#### S-3: Solution
17+
18+
```python
19+
int_text = input("Give me an integer number: ")
20+
int_num = int(int_text)
21+
float_text = input("Give me a float number: ")
22+
float_num = float(float_text)
23+
result = int_num * float_num
24+
print("Your result is: ", result)
25+
```
26+
27+
**[Try It:](/#)**
28+
29+
30+
#### S-4: Shortcut
31+
32+
> You wrote input in one line and then in the next line you used int or float to convert the number. You can write the two lines in one line. Like below
33+
34+
```python
35+
int_num = int(input('Give me an integer number: '))
36+
float_num = float(input('Give me a float number: '))
37+
result = int_num * float_num
38+
print('Your result is: ', result)
39+
```
40+
41+
**[Try It:](/#)**
42+
&nbsp;
43+
#### S-5: Going Forward
44+
45+
Going forward, we will write input and conversion in one line.
46+
47+
#### S-6: Quiz
48+
49+
Which one is used to convert string to a number?
50+
51+
52+
1. number
53+
2. convert
54+
3. int or float
55+
56+
**The answer is: 3**
57+
58+
59+
*S-7: Take Away*
60+
61+
Use int or float to convert user input to a number.
62+
&nbsp;
63+
###### tags: `programmig-hero` `python` `float` `int`
664

7-
| No | <div width="320px"> Description </div> |
8-
| --- | -------------------------------------------- |
9-
| 0 | [introduction](#) |
10-
| 1 | [Easy ones](#) |
11-
| 1.1 | [Convert input](#) |
12-
| 1.2 | [Math power](#) |
13-
| 1.3 | [Random Number](#) |
14-
| 1.4 | [Floor Division](#) |
15-
| 1.5 | [Temporary variable](#) |
16-
| 2 | [Number](#) |
17-
| 2.1 | [Max of two](#) |
18-
| 2.2 | [Max of three](#) |
19-
| 2.3 | [Average of numbers](#) |
20-
| 2.4 | [Divisible by 3 and 5](#) |
21-
| 2.5 | [Sum of digits](#) |
22-
| 2.6 | [Coin sum](#) |
23-
24-
25-
###### tags: `#programming-hero` `#python`

0 commit comments

Comments
 (0)