Page 119 - ComputerGenius_V2.1_Class8
P. 119

Description:

                 In the above program we changed the value of two variables using a third variable ‘temp’.
                 Example 2: Declaring and assigning a value to a variable.
                 Program:
                   website = "apple.com"
                   print (website)
                 Output:
                   apple.com

                 Description:

                 Here website is the name of the variable, apple.com is the value of the variable that is printed.
                 Example 3: Changing the value of a variable.

                 Program:
                   website = "apple.com"

                   print(website)
                   #assigning a new varible to website
                   website = "www.stemrobo.com"
                   print(website)

                 Output:
                   apple.com
                   www.stemrobo.com


                 Description:
                 In the above program, we assigned a value ‘apple.com’ to the variable website initially.

                 Then, its value is changed to ‘www.stemrobo.com’ as python is dynamically typed language.





                    Python is related to AI. As Python has many in-built libraries like Numpy for scientific
                    computation, Scipy for advanced computing and Pybrain for machine learning (Python
                    Machine Learning) making it one of the best languages for AI.




                 Example 4: Assigning multiple values to multiple variables in a single statement.

                 Program:

                   a,b,c =5,3.2,"Hello"
                   print(a)
                   print(b)
                   print(c)



                                                                                            Basics of Python  117
   114   115   116   117   118   119   120   121   122   123   124