Sunday, July 10, 2022

P_Dialogue

 Python runs a dialogue with the user. This first example, 

on the Idle interpreter, always returns a string value between

single quotes. The print command returns whatever is between

either single or double quotes as text...



Below, on the W# Schools python interface, one creates a class and assigns the value

5 to the class' x attribute. Running MyClass or whatever I've called it gets back 

an instruction to run main. Asking for print(x) gets back the value I have stored in x.


                                            


To be clear: just running x would not get 5 on the interface, although it would on the

interpreter.
 

                                                         *     *     *

Below, all instances of the class Lemon will be yellow. Yellow color

is a class attribute of Lemon, which gets passed on to any instance of Lemon.

lemon1, lemon2 and so forth...               


                                                          *     *     *

The main function in Python acts as the point of execution for any program. Defining the main function in Python programming is a necessity to start the execution of the program as it gets executed only when the program is run directly and not executed when imported as a module.


                                                          *     *    *

What about running a class from the interpreter. It can be done, but one must 

open a new file with our program and save it. One then clicks on run...module 

and the output will show up on the interpreter. Seems unduly complex, but it 

means that our demo code will run on the command line as well.

                                                          






                                       

                                                                        



                                      

                                     






No comments: