Difference between revisions of "Python-3.4.3/C2/Getting-started-with-IPython/English"
PoojaMoolya (Talk | contribs) (→Python/C2/Getting-started-with-IPython/English) |
(→Python/C2/Getting-started-with-IPython/English) |
||
Line 186: | Line 186: | ||
|- | |- | ||
| style="border-top:none;border-bottom:0.5pt solid #000000;border-left:0.5pt solid #000000;border-right:0.5pt solid #000000;padding-top:0in;padding-bottom:0.0417in;padding-left:0.0417in;padding-right:0.0417in;"| IPython Terminal | | style="border-top:none;border-bottom:0.5pt solid #000000;border-left:0.5pt solid #000000;border-right:0.5pt solid #000000;padding-top:0in;padding-bottom:0.0417in;padding-left:0.0417in;padding-right:0.0417in;"| IPython Terminal | ||
− | | style="border-top:none;border-bottom:0.5pt solid #000000;border-left:0.5pt solid #000000;border-right:0.5pt solid #000000;padding-top:0in;padding-bottom:0.0417in;padding-left:0.0417in;padding-right:0.0417in;"| Let us see how we can navigate to previous commands in '''IPython''' | + | | style="border-top:none;border-bottom:0.5pt solid #000000;border-left:0.5pt solid #000000;border-right:0.5pt solid #000000;padding-top:0in;padding-bottom:0.0417in;padding-left:0.0417in;padding-right:0.0417in;"| Let us see how we can navigate to previous commands in '''IPython''' |
|- | |- | ||
| style="border-top:none;border-bottom:0.5pt solid #000000;border-left:0.5pt solid #000000;border-right:0.5pt solid #000000;padding-top:0in;padding-bottom:0.0417in;padding-left:0.0417in;padding-right:0.0417in;"| [IPython Terminal] | | style="border-top:none;border-bottom:0.5pt solid #000000;border-left:0.5pt solid #000000;border-right:0.5pt solid #000000;padding-top:0in;padding-bottom:0.0417in;padding-left:0.0417in;padding-right:0.0417in;"| [IPython Terminal] | ||
− | | style="border-top:none;border-bottom:0.5pt solid #000000;border-left:0.5pt solid #000000;border-right:0.5pt solid #000000;padding-top:0in;padding-bottom:0.0417in;padding-left:0.0417in;padding-right:0.0417in;"| For example, say, we want to execute '''print | + | | style="border-top:none;border-bottom:0.5pt solid #000000;border-left:0.5pt solid #000000;border-right:0.5pt solid #000000;padding-top:0in;padding-bottom:0.0417in;padding-left:0.0417in;padding-right:0.0417in;"| For example, say, we want to execute '''print open parenthesis 1 plus 2 close parenthesis.''' |
Line 213: | Line 213: | ||
| style="border-top:none;border-bottom:0.5pt solid #000000;border-left:0.5pt solid #000000;border-right:0.5pt solid #000000;padding-top:0in;padding-bottom:0.0417in;padding-left:0.0417in;padding-right:0.0417in;"| [IPython Terminal] | | style="border-top:none;border-bottom:0.5pt solid #000000;border-left:0.5pt solid #000000;border-right:0.5pt solid #000000;padding-top:0in;padding-bottom:0.0417in;padding-left:0.0417in;padding-right:0.0417in;"| [IPython Terminal] | ||
− | Type '''print | + | Type '''print ('''>> press '''space) '''and press '''Enter'''. |
− | | style="border-top:none;border-bottom:0.5pt solid #000000;border-left:0.5pt solid #000000;border-right:0.5pt solid #000000;padding-top:0in;padding-bottom:0.0417in;padding-left:0.0417in;padding-right:0.0417in;"| Type the word '''print | + | | style="border-top:none;border-bottom:0.5pt solid #000000;border-left:0.5pt solid #000000;border-right:0.5pt solid #000000;padding-top:0in;padding-bottom:0.0417in;padding-left:0.0417in;padding-right:0.0417in;"| Type the word '''print open parenthesis '''and press '''space key close parenthesis '''on the keyboard. |
Line 252: | Line 252: | ||
− | As with any programming language, '''asterix '''is used for multiplication | + | As with any programming language, '''asterix '''is used for multiplication operator. |
|- | |- | ||
Line 445: | Line 445: | ||
− | 2.0 | + | '''round(2.48) <nowiki>= 2.0</nowiki>round(2.48, 1)<nowiki>= 2.5</nowiki> round(2.484) <nowiki>= 2.0 </nowiki>round(2.484, 2) <nowiki>= 2.48 </nowiki>''' |
− | + | ||
− | 2.5 | + | |
− | + | ||
− | 2.0 | + | |
− | + | ||
− | 2.48 | + | |
Line 469: | Line 463: | ||
− | Type '''round | + | Type '''round open parenthesis 2.484''' and press '''Enter''', without closing the parenthesis. |
Revision as of 17:56, 8 February 2017
Python/C2/Getting-started-with-IPython/English
Title of script: Getting started with IPython
Author: Puneeth, Jovina, Thirumalesh H S
Keywords: Python, IPython
|
|
Show Slide
[Slide with MHRD logo] |
Hello Friends. Welcome to the spoken tutorial on "getting started with IPython". |
Show Slide
Objectives
|
At the end of this tutorial, you will be able to,
|
Show Slide
System Specifications |
To record this tutorial, I am using
|
Show Slide:
What is IPython |
What is IPython?
|
[Terminal]
Type ipython >> press Enter |
Let us first see how to start the IPython interpreter.
If IPython is not installed, please refer to the instructions sheet. |
[IPython Terminal]
Point to the version information with mouse. |
If IPython is installed, the IPython interpreter is loaded by running the ipython command in the terminal
|
[IPython Terminal]
Point to In[1]: prompt with mouse |
Some additional helpful information is printed by IPython.
|
[IPython Terminal]
Type Ctrl+D |
Now, Let us see how we can quit the IPython interpreter.
|
]IPython Terminal]
|
A prompt will appear to confirm if we really want to exit.
We could also press Enter and it will exit.
|
[IPython Terminal]
|
Let us type y.
|
[Terminal]
Type ipython >> press Enter |
Let us start it again.
|
[IPython Terminal] | Now, Let us learn how to use the interpreter.
|
[IPython Terminal]
1+2 Point at the Out[1] prompt
|
Type 1 plus 2 at the IPython prompt and press Enter.
|
[IPython Terminal]
5 – 3 7 * 4 |
Let us now try a few more operations such as,
5 minus 3, 7 multiplied by 4,
|
IPython Terminal | Let us see how we can navigate to previous commands in IPython |
[IPython Terminal] | For example, say, we want to execute print open parenthesis 1 plus 2 close parenthesis.
|
[IPython Terminal]
Use the up arrow key to go back to the command 1+2. |
Use the up arrow key to go back to the command 1 plus 2. |
[IPython Terminal]
Use left arrow to navigate to start of line |
Now use the left-arrow key to navigate to the beginning of the line.
|
[IPython Terminal]
Type print (>> press space) and press Enter.
|
Type the word print open parenthesis and press space key close parenthesis on the keyboard.
|
[IPython Terminal]
Highlight the result line.
|
The interpreter prints the result as 3.
|
[IPython Terminal]
Press up-arrow key |
Now let us execute print 10 multiplied by 2.
We use the up arrow key to navigate to the previous command print (1 plus 2). |
[IPython Terminal]
Change print (1+2) to print (10*2) |
Now replace 1 plus 2 with 10 multiplied by 2 and press Enter.
|
[IPython Terminal]
Highlight output |
Observe the output on the console.
<<PAUSE>> |
[IPython Terminal] | Now, Let us see, what is tab-completion.
|
[IPython Terminal]
pri<tab> |
Suppose we want to use the function print.
|
[IPython Terminal] | As you can see on the console that IPython has autocompleted the command pri to print.
|
[IPython Terminal]
p<tab> |
Let us see some more possibilities of tab completion.
|
[IPython Terminal] | In this case, we see that IPython does not complete the command.
|
Show Slide:
Exercise 1 |
Now Let us try out an exercise.
|
[IPython Terminal]
a<tab> |
ab tab autocompletes to abs.
|
[IPython Terminal] | Now, Let us see what the function abs is used for.
|
[IPython Terminal] | To see the documentation of a function, type the function name followed by a question mark.
|
[IPython Terminal]
Type abs? >> press Enter
|
Type abs? and press Enter. From the displayed information, it says abs accepts a number as input and returns it's absolute value. |
[Ipython Terminal]
abs(-19) abs(19) |
Let us see few examples,
|
[Ipython Terminal]
abs(-10.5) |
Now Let us try it for decimal numbers.
|
Show Slide
Exercise 2 round? |
Pause the video here.
Try out the following exercise and resume the video.
|
[IPython Terminal]
Type round?
|
Switch to the console for the solution.
|
[IPython Terminal]
Highlight the syntax of ndigits |
ndigits is the precision value for round function.
|
Show Slide
Exercise 3 |
Pause the video here.
Check the output of round(2.48) round(2.48, 1)round(2.484) round(2.484, 2) |
Show Slide
Solution 3 |
We get
|
[IPython Terminal]
Press Enter |
Let us now see how to correct typing errors, which we could make while typing on the console.
|
[IPython Terminal]
Point at the prompt with three dots
|
We get a prompt with dots.
|
Type ) >> press Enter | Now complete the command with close parenthesis and press Enter.
|
[IPython Terminal]
|
What if we type an incorrect command and end up with the continuation prompt?
|
Show Slide
Exercise 4 |
Pause the video here.
|
[IPython Terminal]
round(2.484 Ctrl+C round(2.484, 2) |
The output on your console should look like this. |
Show Slide
|
This brings us to the end of this tutorial.
|
Show Slide
Assignment
|
Here are some self assessment questions for you to solve
|
Show Slide
Solutions
|
And the answers are-
|
Show Slide
About the Spoken Tutorial Project
|
This video summarises the Spoken Tutorial project.
|
Show Slide
Spoken tutorial workshops |
We conduct workshops using Spoken Tutorials.
Give Certificates. Please contact us. |
Show Slide
Forum to answer questions |
Do you have questions in THIS Spoken Tutorial?
Choose the minute and second where you have the question. Explain your question briefly. Someone from the FOSSEE team will answer them. Please visit this site. |
Show Slide
Forum to answer questions |
Do you have any general / technical questions on Python?
Please visit the FOSSEE forum and post your question. |
Show Slide
Textbook Companion |
The FOSSEE team coordinates coding of solved examples of popular books.
We give honorarium and certificates for those who do this. For more details, please visit this site. |
Show Slide
Acknowledgement |
The Spoken Tutorial project is funded by NMEICT, MHRD, Govt. of India |
Show Slide
Thank You |
This is __________ from IIT Bombay signing off. Thanks for watching |