Lockdown Offer: FLAT 75% + Addl. 25% Off + 30-days Extra Lab on ALL Courses | Use Coupon Code LD25 during Checkout | Offer Expires In

  Enroll Now

Python - Videos and Questions

18 / 78

Python - Variable Assignment

In Python, a variable allows us to refer to a value with a name. To create a variable use "=" like below

x = 10

Here, we have assigned integer value 10 to x.

Instructions -

Create variables in the Jupyter notebook on the right-hand side. Press "Shift + Enter" to run code in individual cells.

  • Create a variable my_int with the value 20. Since 20 is an integer, my_int is an integer variable.

  • Create a variable my_float with the value 15.85. Here my_float is a float variable.

  • Create a variable my_string with value 'Hello World'. Here my_string is a string variable. In Python string can be defined using single or double quotes.

  • Create a variable my_bool with the value True. Here my_bool is a boolean variable and represent the logical values True or False(Note the capitalization)


Note - Having trouble with the assessment engine? Check this discussion