Web Development and Design | Tutorial for Java, PHP, HTML, Javascript: python-data-types

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

Python Removing key-value pairs

Python Removing key-value pairs




Removing key-value pairs

You can remove any key-value pair you want from a dictionary. To do so use the del keywords and dictionary name, followed by the key in square brackets. This will delete the key and its associated value.

#Deleting a key-value pair
alien_0 = {'color': 'green', 'points': 5}
print(alien_0)

del alien_0['points']
print(alien_0)

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