PieceOfAPie
PieceOfAPie
  • Home
  • Tutorials
  • More
    • Home
    • Tutorials
  • Home
  • Tutorials

Data Types

Previous Lesson 


Just like in English, there are adjectives, nouns, pronouns, and more, in Python we have data types. Some data types in python are:

  • String - A list of characters in quotation marks. (Represented by keyword "str").
    •  String


  • Integer - A number that is not a decimal/fraction. (Represented by keyword "int").
    •  Integer 


  • Float - A number that is a decimal/fraction. (Represented by keyword "float").
    •  Float


  • Boolean - True or False. Nothing else. Just True or False. (Represented by keyword "bool").
    •  Boolean

 

Variables

A variable is something that represents a term. Examples of variables are:

  •  Examples


You can assign a variable by saying the variable name, putting an equal sign, and then putting the term that the variable represents. 

  • variable = term


You can also change existing variables just by writing the variable name again and then writing the new value.

  •  Examples


As you can see above, in the first line, the variable was equal to "Hi how are you?" and in the second line, the variable changed to "What's your name?".

Data Types and Variables Exercise

In this list, determine the data type of each item.

  1. "Hello"
  2. 34.5
  3. 67
  4. True
  5. 6.0
  6. False
  7. "56"


  1. x = 5
  2. print("x")
  3. x = 10
  4. print(x)

Next Lesson

Operators and Boolean Expressions

Copyright © 2024 PieceOfAPie - All Rights Reserved.

Powered by GoDaddy

This website uses cookies.

We use cookies to analyze website traffic and optimize your website experience. By accepting our use of cookies, your data will be aggregated with all other user data.

Accept