Page 120 - ComputerGenius_V2.1_Class8
P. 120

Output:
                    5
                    3.2
                    Hello

                  Description:
                  In the above program, we assigned different values to different variables in one statement. It is
                  one of the interesting features of Python, where multiple variables can be declared using a single
                  statement and each variable is separated from other by comma.

                  Example 5: Assigning same value to multiple variables.

                  Program:
                    a=b=c ="Same"
                    print(a)

                    print(b)
                    print(c)
                  Output:

                    Same
                    Same
                    Same

                  Description:
                  In the above program, we assigned same value to different variables. All type of values like integer,
                  float, Boolean etc. can be assigned to different variables at same time.
                  Example 6: Arithmetic operators in Python.

                  Program:
                    x = 15
                    y = 4

                    print('x+y=', x+y)
                    print('x-y=', x-y)
                    print('x*y=', x*y)
                    print('x/y=', x/y)
                    print('x//y=', x//y)
                    print('x**y=', x**y)

                  Output:
                    x + y = 19
                    x - y = 11
                    x * y = 60
                    x / y = 3.75
                    x // y = 3

                    x ** y = 50625

                       118   Computer Genius (V2.1)-VIII
   115   116   117   118   119   120   121   122   123   124   125