Python (Fall 2026) Module 2-3: Data Types
Overview
Bill Moseley introduces four Python data types: strings, integers, floating-point numbers, and Booleans, explaining how their properties affect program design. He recommends readable camel-case variable names with type prefixes, then demonstrates assigning values and using print() to inspect strings, numbers, and Boolean values.
Key takeaways
- Use a floating-point type for values such as a 3.8 GPA because an integer cannot preserve the decimal portion.
- Python strings preserve character order and case, and individual characters cannot be edited in place; assign a replacement string instead.
- Python recognizes Boolean literals only when written as True or False with an initial capital and no quotation marks.
- Type-prefixed camel-case names such as intAge and floatGPA make a variable's intended type and meaning easier to identify.
- Calling print() on a variable is a straightforward way to check its current value, whether it contains text, a number, or a Boolean.
Chapters
- A string is an ordered sequence of characters; individual characters cannot be changed in place, though the variable can be assigned a different string.
- Integers represent whole numbers, while floating-point numbers represent decimals; a float assigned 12 is represented as 12.0.
- Python Boolean literals must be capitalized as True or False and written without quotation marks.
- A student's GPA should use a float so values such as 3.8 can be represented; database records often use a primary key or unique identifier.
- Moseley recommends names such as strName, intAge, floatGPA, and boolLikeMe to communicate both data type and purpose.
- Camel case capitalizes the start of each new word, making names such as strFirstName easier to read than lowercase words run together.
- Variable names should balance brevity with clarity; strFirstName is more practical than a long name describing every detail.
- The Hello World exercise is revised to assign a greeting string to strGreeting and display it by passing the variable to print().
- Python's print() function can display strings, numbers, and Boolean values, making it a simple way to inspect a variable during a program.
- Writing lowercase true causes Python to look for a variable named true; the Boolean literal must be written as True or False.
Transcript excerpt
0:01 Programs or variables can contain lots of different types of data. In fact, variables can contain almost any type of thing in programming, or in Python. But here are the four types that I'm going to start with. Okay? And we need to know the difference between these things because it will impact how you do a program. The first type we've already played around with, called the string, or string literal. It's just a list of characters. The list of characters always stays in that same order. It stays in that same case. And you can't actually change just one letter in that. You can replace that string with a different string in the variable, but there's
0:52 no mechanism in Python for just changing, let's say I wanted to capitalize this N. I can't change just that. I could replace it with a new string with a capital N, but I can't just change one character. Strings are very simple. And that's a good thing and a difficult thing. We will work with strings throughout this whole class, lots and lots. An integer is any number without decimals. So it's any whole number. It can be positive or negative. It can be zero. And for all intents and purposes in this class, it goes from infinity negative to infinity positive. Now, there are actual limitations for how big an integer can be in Python.
1:46 But none of those are relevant to anything we're going to be doing in this class. So we're just not going to worry about it. For all intents and purposes, it's pretty infinite. But it's whole numbers. If I want a decimal or a partial number, like 13.985, it's a floating point number. Also known as a float. So if I say we're going to create a float
This is the start of the transcript. Save this video free for the whole transcript, searchable and time-coded.
In this course
Related notes
Summary, takeaways, and chapters were generated by AI from the video's transcript and may contain errors. The video belongs to its creator, Bill Moseley, Ph.D. - Computer Science Educator.