Skip to content

Commit 9ad2c75

Browse files
SSwiniarskiyangc95
andauthored
Python data types (Codecademy#500)
* Update data-types.md * Update data-types.md * Combined output and code block * Update content/python/concepts/data-types/data-types.md Co-authored-by: Christine Yang <[email protected]> * Update data-types.md * Update data-types.md * Update data-types.md Co-authored-by: Christine Yang <[email protected]>
1 parent 015f78f commit 9ad2c75

File tree

1 file changed

+9
-22
lines changed

1 file changed

+9
-22
lines changed
Lines changed: 9 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
Title: 'Data Types'
3-
Description: 'Python is a strongly typed language. Strongly typed means that the data type of a value doesnt change in unexpected ways. py codecademy = 575 codecademy = "575 broadway" After line 1, codecademy is an int. After line 2, codecademy is a str. Here are Pythons built-in data types:'
3+
Description: 'Python is a strongly typed language. At runtime, it prevents typing errors and engages in little implicit type conversion.'
44
Subjects:
55
- 'Computer Science'
66
- 'Data Science'
@@ -14,7 +14,7 @@ CatalogContent:
1414
- 'paths/computer-science'
1515
---
1616

17-
Python is a strongly typed language. Strongly typed means that the data type of a value doesn't change in unexpected ways.
17+
Python is a strongly typed language, in the sense that at runtime it prevents typing errors and it engages in little implicit type conversion or [casting](https://www.codecademy.com/resources/docs/python/casting), i.e. converting one type to another without a specific call to a conversion function.
1818

1919
```py
2020
codecademy = 575
@@ -23,7 +23,7 @@ codecademy = "575 broadway"
2323

2424
After line 1, `codecademy` is an `int`. After line 2, `codecademy` is a `str`.
2525

26-
Here are Python's built-in data types:
26+
Python includes the following categories of built-in data types:
2727

2828
- String type: `str`
2929
- Boolean type: `bool`
@@ -35,38 +35,25 @@ Here are Python's built-in data types:
3535

3636
## type()
3737

38-
To find the data type of any object, the `type()` function can be used:
38+
The `type()` function can be used to retrieve the data type of an object:
3939

4040
```py
4141
message = "Hello, world!"
4242

4343
print(type(message))
44-
```
45-
46-
This will output:
47-
48-
```shell
49-
<class 'str'>
44+
# Output: <class 'str'>
5045
```
5146

5247
## isinstance()
5348

54-
You can also use the built-in `isinstance()` function to test if a variable is an instance of a specified type:
49+
The `isinstance()` function can be used to test if an object is an instance of a specified type. This will print a boolean value for each function call, indicating if the object is an instance of the given type:
5550

5651
```py
5752

5853
word = "purple"
5954
languages = ("Python", "JavaScript", "Go")
6055

61-
print(isinstance(word, str))
62-
print(isinstance(languages, list))
63-
print(isinstance(languages, tuple))
64-
```
65-
66-
This will print a boolean value for each function call indicating if the object is an instance of the given type:
67-
68-
```shell
69-
True
70-
False
71-
True
56+
print(isinstance(word, str)) # Output: True
57+
print(isinstance(languages, list)) # Output: False
58+
print(isinstance(languages, tuple)) # Ouput: True
7259
```

0 commit comments

Comments
 (0)