Web Development and Design | Tutorial for Java, PHP, HTML, Javascript: python-print-variable

Web Development and Design | Tutorial for Java, PHP, HTML, Javascript: python-print-variable
Showing posts with label python-print-variable. Show all posts
Showing posts with label python-print-variable. Show all posts

Python Modifying Values

Python Modifying Values



Modifying values

You can modify the value associated with any key in a dictionary. To do so give the name of the dictionary and enclose the key in sqaure brackets, then provide the new value for that key.

#Modifying values in a dictionary
alien_0 = {'color': 'green', 'points':5}
print(alien_0)

#change the aliein's color and point value.
alien_0['color'] = 'yellow'
alien_0['points'] = 10
print(alien_0)

Screenshot 

 

Python variables Assignment

Python variables Assignment



Variables in Python

Variables are nothing but reserved memory locations to store values. This means that when you create a variable you reserve some space in memory.




code
#assignment=binding of a name with a value 
#1. evaluation of right side expression value
#2. assignment in order with left side names
x=1.2+8+sin(y)
a=b=c=0 #assignment to some value
y, z, r=9.2, -7.6, 0 #multiple assignment
a, b=b, a #values swap
a, *b=seq #unpacking of sequence in
*a, b=seq #item and list
x+=3 #increment=x=+3
x-=2 #decrement=x=x-2
x=None #undefined (constant value)
del x #remove name x