VARIABLES AND DATATYPES

Variables in Python | Part 3

Introduction ????????

In this post, Let’s see about variables in python and it’s examples. Below is the video format of the post, Check that also ????????

Video ????

What is Variables in Python ????

In Python, variables are used to store values that can be accessed and manipulated throughout the program.

Here’s how you can declare and use variables in Python ????????

1. Variable Declaration

You can declare a variable in Python by assigning a value to it using the assignment operator (=).

Python is a dynamically typed language, so you don’t need to explicitly specify the variable’s type.

2. Variable Naming Rules

  • Variable names can contain letters (a-z, A-Z), digits (0-9), and underscores (_). However, they must start with a letter or an underscore.
  • Variable names are case-sensitive, meaning myVar and myvar are considered different variables.
  • Python keywords (reserved words like if, while, for, etc.) cannot be used as variable names.

3. Python Data Types

Python is a dynamically-typed language, meaning you don’t need to specify the data type explicitly.

The type is inferred based on the value assigned to the variable. Some common data types in Python include.

  • Integer int(): whole numbers without decimal points (e.g., 42)
  • Float float(): numbers with decimal points (e.g., 3.14)
  • String str(): a sequence of characters (e.g., “Hello, World!”)
  • Boolean: represents either True or False
  • Byte byte(): represent a sequence of binary data
  • List list(): Collections of different types of values and separated using square brackets.
  • Tuples tuple(): List of values and separated using parenthesis
  • Dictionary dict(): Dictionary are similar to databases has a value for each class

I have given some examples for python data types check it out ????????

Integers & Float

Strings

Boolean

Bytes

List

Tuples

Dictionary

type ()

The type function allows us to understand which data type is the code, For example let’s enter the below code and check the output.

type("hello")

https://replit.com/@MoulikC/VariablesPython


Ads Blocker Image Powered by Code Help Pro

Ads Blocker Detected!!!

We have detected that you are using extensions or brave browser to block ads. Please support us by disabling these ads blocker.Our website is made possible by displaying Ads hope you whitelist our site. We use very minimal Ads in our site

 

Scroll to Top