Responsive Advertisement

Learn Python: Learning by doing

1. Variables and Operations

computers can store and manipulate data using variables. Python is a high-level programming language that allows its users to create and manipulate those variables very concisely compared to other programming languages like C, Java, etc.

In this section, we will take into a basic Python with a focus on CRUD(Create, Read, Update, and Delete) for data manipulation. we will learn how to create and manipulate variables for each data type (e.g. string, integer, etc.) using Python.

Definition:

1. Python variables: Understanding the definition and characteristics of python variables. Variables are containers for storing data values.

2. Basic Data and operation: Understanding Python data types and operators.

What is a Variable?

In Python, a variable is a reserved memory space (identified by a memory address) paired with an associated symbolic name in the data storage.

Variable in Python

In Python, a variable can store data under a symbolic name, and the name is used for data access.

You can assign values, variables, or even results of operations to a variable.

Assigning a value to a variable

In Python, you can create a variable by assigning a value to it using an assignment operator = . It's also possible to overwrite an existing variable with a new value of any data type.

  
  	a = True # Boolean (true or false)
	x = 1 # Integer
	f = 1.2 # Float
	s = "string" # String
	lst = [1,2,3,4,"a","b","c","d"] # List
  

# To preview or to call the value of variable. We just simply do as below ...

  
  print("The Boolean value",x)
  print("The integer number is",i)
  print("The float number is",f)
  print("String",s)
  print("Value in the list form", lst)
  

# Overwriting x of the value 1 with a new value 'Hello Python'

  
  x = "Hello Python"
  

In Python, it will simply take latest assign value to store in the memory.

Post a Comment

0 Comments