Skip to content

Commit 67c8048

Browse files
authored
Update type-conversion.md (#62)
1 parent 0e9478b commit 67c8048

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

docs/type-conversion.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,20 @@ Type conversion is a common requirement in programming, and both Python and Java
99

1010
### Task
1111

12-
Assuming there is a hard disk with a capacity of 8192MB (as a string), please convert the capacity of this hard disk to the TB unit and save the conversion result in an integer variable.
12+
Assuming there is a hard disk with a capacity of 8192MB (as a string), please convert the capacity of this hard disk to the GB unit and save the conversion result in an integer variable.
1313

1414
#### JavaScript implementation
1515
```javascript
16-
let gb = '8192MB';
17-
let tb = parseInt(gb) / 1024
18-
let intTb = parseInt(tb)
19-
console.log(`The capacity of this hard disk is: ${intTb}TB`)
16+
let mb = '8192MB';
17+
let gb = parseInt(mb) / 1024
18+
let intGb = parseInt(gb)
19+
console.log(`The capacity of this hard disk is: ${intGb}GB`)
2020
```
2121
#### Python implementation
2222
```python
23-
gb = '8192MB'
24-
int_tb = int(gb[:-2]) // 1024
25-
print(f"The capacity of this hard disk is: {int_tb}TB")
23+
mb = '8192MB'
24+
int_gb = int(mb[:-2]) // 1024
25+
print(f"The capacity of this hard disk is: {int_gb}GB")
2626
```
2727

2828
### Code Highlight

0 commit comments

Comments
 (0)