You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.'
4
4
Subjects:
5
5
- 'Computer Science'
6
6
- 'Data Science'
@@ -14,7 +14,7 @@ CatalogContent:
14
14
- 'paths/computer-science'
15
15
---
16
16
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.
18
18
19
19
```py
20
20
codecademy =575
@@ -23,7 +23,7 @@ codecademy = "575 broadway"
23
23
24
24
After line 1, `codecademy` is an `int`. After line 2, `codecademy` is a `str`.
25
25
26
-
Here are Python's built-in data types:
26
+
Python includes the following categories of built-in data types:
27
27
28
28
- String type: `str`
29
29
- Boolean type: `bool`
@@ -35,38 +35,25 @@ Here are Python's built-in data types:
35
35
36
36
## type()
37
37
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:
39
39
40
40
```py
41
41
message ="Hello, world!"
42
42
43
43
print(type(message))
44
-
```
45
-
46
-
This will output:
47
-
48
-
```shell
49
-
<class 'str'>
44
+
# Output: <class 'str'>
50
45
```
51
46
52
47
## isinstance()
53
48
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:
55
50
56
51
```py
57
52
58
53
word ="purple"
59
54
languages = ("Python", "JavaScript", "Go")
60
55
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:
0 commit comments