Data Types in Python: Python has various built-in data types. Some common ones are: - *int*: For integers (e.g., 1, -3, 100) - *float*: For floating-point numbers (e.g., 3.14, -0.001) - *str*: For strings (e.g., "Hello", "Python") - *bool*: For boolean values (True or False) Type Checking: You can use the `type()` function to check the type of a variable. Ex: a = 10 print ( type ( a )) #output:<class 'int'> Type Conversion: Python allows you to convert between data types using functions like `int()`, `float()`, `str()`, etc. Ex: x = "10" # x is a string y = int ( x ) # Convert string to integer z = float ( y ) # Convert integer to float print ( z ) # Output: 10.0 Assigning Values to Multiple Variables: Python allows you to assign values to multiple variables in a single line. Ex: x , y , z = 10 , 20 , 30 print ( x ) # Output: 10 print ( y ) # Output: 20 print ( z ) # Output: 30 You can also assign the same value to m...
Posts
Showing posts from February, 2026
- Get link
- X
- Other Apps
Variables in Python are used to store data values. A variable is created the moment you assign a value to it. Python is dynamically typed , which means you don’t need to declare the type of a variable explicitly. Syntax for Variable Assignment x = 10 # Assigning an integer value to x y = "Good Morning" # Assigning a string value to y Variable Naming Rules Variable names can contain letters (a–z, A–Z), numbers (0–9), and underscores (_) Variable names must start with a letter or an underscore Variable names are case-sensitive ( Name and name are different) Example age = 25 name = "John" is_student = True Age=30 Note: age and Age are treated as two different variables in Python because variable names are case-sensitive. What’s Next? This is Day 2 of Python Basics . In the next post, we’ll cover operators, user input, and simple Python programs . Make sure to bookmark this page and check back for the next lesson. If thi...
Introduction to python for beginners
- Get link
- X
- Other Apps
Python is one of the easiest programming languages for beginners. It is used in: Web development Data Science Artificial Intelligence DSA and placements My blog focuses on: step-by-step instructions fundamental Data Structure concepts coding examples for practice preparation for academics and placement First Python Program This is the first basic program in Python Program: print(" Hello World ") Output: Hello World This program prints a message on the screen using the print() function