Different Data Types

Introduction to Data Types

Exercise 1

Identify the data types for the following
  1. Total students present in the class
  2. Course code of a subject
  3. Room temperature
  4. NYU student ID
  5. Home address
  6. Day of the week (Sunday, Monday, etc)
  7. Price of a book
  8. CGPA of a student

Variables

For example, the variable fname is used to store the first name of a person. The first name of a person is of type text or string.

Data Types in Python 2

Rules for naming a Variable

Exercise 2

Identify valid variable names from the following

  1. max_price
  2. Total students
  3. US$
  4. student_id
  5. as, for, in, import (reserved words in Python)
  6. discount20
  7. 1st_student

Using Variables

What if you want to change the size of the square from 100 to 50 dots?

Using Variables, extended

Arithmetic Operators

Data Types in Python 5

Exercise 3

Convert the following mathematical expression to Python expression

Data Types in Python 6

Precedence Rules

Data Types in Python 7

Exercise on Precedence Rules

Evaluate the following expressions using the operator precedence.

Data Types in Python 8
For more details, please contact me here.