0% found this document useful (0 votes)
2 views2 pages

Python Variable Assignment Guide

The document provides examples of variable assignment and rules for naming variables in Python. It emphasizes that variable names must start with an alphabet or underscore, cannot contain spaces, and are case-sensitive. Additionally, it notes that keywords should not be used as variable names.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views2 pages

Python Variable Assignment Guide

The document provides examples of variable assignment and rules for naming variables in Python. It emphasizes that variable names must start with an alphabet or underscore, cannot contain spaces, and are case-sensitive. Additionally, it notes that keywords should not be used as variable names.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

In [2]: # assigning a value to a variable.

a=10
print(a)

10

a=10 b=20 print(a) print(b) print(a+b)

In [5]: a,b=10,20

print(a)
print(b)

10
20

In [6]: x=5
y=5
print(x)
print(y)

5
5

In [7]: x=y=5
print(x)
print(y)

5
5

In [9]: #Variale should start with alphabet or underscore(_)


age=10
_age=12
print(age)
print(_age)
# @age=10 gives error
# variabble should not contain space in between

10
12

In [14]: #It should not start with numerical value and it can come inbetween or end
value1=15
print(value1)

15

In [11]: #It can be alphanumeric


num123=5
print(num123)

In [15]: #It is case sensitive


a=12
A=15
print(a)
print(A)
number=12
Number=12
print(number)
print(Number)

12
15
12
12

In [17]: #no keywords should be use in variable


#such as print, if, while, do , for...

You might also like