Variables and Data Types in Python

 Variables and Data Types in Python


Variables in Python are used to store data values. Here's an example:


python


x = 5

y = "Hello"

print(x)

print(y)

In this example, x is an integer variable with a value of 5 and y is a string variable with a value of "Hello".


Python supports several data types including integers, strings, floats, and booleans. Here's an example:


python


x = 5

y = 5.0

z = "Hello"

a = True


print(type(x))

print(type(y))

print(type(z))

print(type(a))

In this example, x is an integer, y is a float, z is a string, and a is a boolean. The type() function is used to print the data type of each variable.

No comments:

Post a Comment

The Importance of Cybersecurity in the Digital Age

 The Importance of Cybersecurity in the Digital Age Introduction: In today's digital age, where technology is deeply intertwined with ev...