codewithronny logo
codewithronny logo
  • Category
    • Adsense
    • Blog
    • Boilerplate
    • CodeWithRonny
    • Course Review
    • How to
    • HTML Tutorial
    • JavaScript
      • JavaScript Tutorial
    • Laravel
    • Machine Learning
      • Machine Learning Tutorial
    • MySQL
      • MySQL Tutorial
    • Networking
    • PHP Tutorial
    • Python
      • Data Structure Using Python
      • Python Interview Question
      • Python Tutorial
    • Python Coding Interview Practice
    • Server
      • Share Hosting
    • Tech Celebrity
    • Web Technologies and Development
    • Wordpress
      • Theme
  • Information
    • Contact Us
    • About Us
    • Privacy Policy
    • Terms
    • Disclaimer
  • Code Editor
    • HTML Code Editor
    • Python Code Editor
Python Tutorial
Python TutorialPython VariablesVariables Name in PythonPython Variables - Multiple Value AssignmentPython Data Types

Python Variables


Variables

Variables are simply a container for storing values.


Create Variables

Python has no key for declaring variables, Variables are created when you assign a value to it.

a = 5
b = "Earth"

print(a)
print(b)

In Python do not need to declare the variables type, variable type automatically assigned when you will assign a value and variables types can be changed after assigning the value.

a = 5 # a is an integer type of variable
b = "Earth" # b is an string type of variable
c = 5.5 # c is an float type of variable

print(a)
print(b)
print(c)

Casting

You can declare the data types of a variables, by using casting. Python have built-in function for declaring the data type. There is lots of casting but we will see only about three.

  • int() This is an Python built-in function used for declaring Integer Data Types.
  • str() This Python str Function used to declare String Data Types.
  • float() This is an float function used for declaring Float Data Types. This function also used for converting Integer to Float data types.
int() # This is an int function
str() # This is an str function
float() # This is an float function

How To Use Castings in Python

See here in this example we will learn how we can cast an data type by using python built-in function.

a = int(5) # We casting 5 as integer data types to 'a' variable
b = str('Earth') # We casting "Earth" as string data types to 'b' variable
c = float(5.5) # We casting 5.5 as float data types to 'c' variable


print(a)
print(b)
print(c)

Get Data Types

We will learn how to check or get the data types of variables. We will use type() function to check the data types.

a = 5

print(type(a))

Print Message in Python

print() this is an function for printing any message in human readable form.

print('Hello')
print(5)






codewithronny logo
codewithronny logo

A Tutorial Cafe

  • Twitter
  • Facebook
  • Instagram
  • Linkedin
  • Linkedin
Company
    About Us
  • Contact Us
  • Career
Community
    Documentation
  • Faq
  • Sitemap
Explore
    Terms & Conditions
  • Privacy policy
  • Disclaimer
  • Affiliate Disclosure
  • Become an Author
  • How to guide
Contact


Copyrights ©2024 CodeWithRonny
  • GlobeLanguage Chevron
    • English
    • Hindi
  • Terms of use
  • Cookies
  • Sitemap