Sunday, 19 March 2017

Python programming part-1 The Python Console


                             Your First Program                              

In the lesson , we will start using Python , via the Python console. The first step is to download Python from www.python.org

You should download the Python 3.x version that is complitable with your operating system. Once installed , the Python console can be accessed using once of several ways, including using the command line, runing the Python interepreter directly, or runing a GUI that comes installed with Python called IDLE.

We'll use all of these ways during this course, but we'll start with IDLE , as it is the easiest.

After runing IDLE, you should see a prompt of three right arrows. Type in "print("Hello World ! ")" and press enter. You should see the following :

>>> print ('Hello World')
Hello World

Congratulation ! You have written your first program.


Q) Fill in the blanks to print "Hi" .
 >>>_____("Hi")

Ans          print ("Hi")


                    The Python Console                                 

Part-1:

The Python console is a program that allows you to enter one line of Python code, repeatedly executes that line, and displays the output. This is known as a REPL - a read-eval-print loop. After the   "print ('Hello World')"  line's output has been displayed, you can re-enter the code , and you will get the same output again. Try entering the same code, but with different text :

>>>print ('Hello World !')
Hello World !
>>>print ('Hello World !')
Hello World !
>>>print ('Spam and eggs...')
Spam and eggs...


     Python code often contains  references to the comedy group               Monty Python . This is why the words, "spam" and "eggs" are         often used as placeholder variables in Python where "foo" and    "bar" would be used in other programming languages.                   


Q) Fill in the blank to output "ni ni ni" .

>>> _______('ni ni ni'___

ans: print('ni ni ni)

____________________________________________________




                    The Python Console                                 

Part 2 :

When finished with the python console , you will want to close it . You can close IDLE in the same way you close other programs on your operating system, but other kinds of consoles must be closed by different methoods. To close a console , type in "quite()" or "exit()" , and press enter .


>>> quite( )


Q) Whice of these options closes the Python console ?
     
       a) quit( )
       b) quit
       c) end ( )

______________________________________________________
                                                                                                            


EmoticonEmoticon