Difference between revisions of "Python-3.4.3/C3/Basic-datatypes-and-operators/English"
(Created page with " {| style="border-spacing:0;" | style="background-color:#ffffff;border:0.5pt solid #000001;padding-top:0cm;padding-bottom:0cm;padding-left:0.097cm;padding-right:0.191cm;"| <ce...") |
Nancyvarkey (Talk | contribs) |
||
Line 6: | Line 6: | ||
|- | |- | ||
| style="background-color:#ffffff;border:0.5pt solid #000001;padding-top:0cm;padding-bottom:0cm;padding-left:0.097cm;padding-right:0.191cm;"| Slide containing title | | style="background-color:#ffffff;border:0.5pt solid #000001;padding-top:0cm;padding-bottom:0cm;padding-left:0.097cm;padding-right:0.191cm;"| Slide containing title | ||
− | | style="background-color:#ffffff;border:0.5pt solid #000001;padding-top:0cm;padding-bottom:0cm;padding-left:0.097cm;padding-right:0.191cm;"| Welcome to the spoken tutorial on "'''data types and | + | | style="background-color:#ffffff;border:0.5pt solid #000001;padding-top:0cm;padding-bottom:0cm;padding-left:0.097cm;padding-right:0.191cm;"| Welcome to the spoken tutorial on "'''data types and operators'''". |
|- | |- | ||
Line 21: | Line 21: | ||
** Boolean and | ** Boolean and | ||
* '''Operators '''in''' Python''' like | * '''Operators '''in''' Python''' like | ||
− | ** Arithmetic | + | ** Arithmetic operators and |
− | ** Boolean | + | ** Boolean operators |
− | + | ||
− | + | ||
|- | |- | ||
Line 35: | Line 33: | ||
* '''Python 3.4.3 '''and | * '''Python 3.4.3 '''and | ||
* '''IPython 5.1.0''' | * '''IPython 5.1.0''' | ||
− | |||
− | |||
|- | |- | ||
Line 46: | Line 42: | ||
* you should know how to run basic '''Python '''commands on the '''ipython console.''' | * you should know how to run basic '''Python '''commands on the '''ipython console.''' | ||
* If not, see the relevant '''Python '''tutorials on this website. | * If not, see the relevant '''Python '''tutorials on this website. | ||
− | |||
− | |||
|- | |- | ||
Line 54: | Line 48: | ||
'Numbers' | 'Numbers' | ||
− | | style="background-color:#ffffff;border:0.5pt solid #000001;padding-top:0cm;padding-bottom:0cm;padding-left:0.097cm;padding-right:0.191cm;"| There are three built-in data types in Python to represent numbers. | + | | style="background-color:#ffffff;border:0.5pt solid #000001;padding-top:0cm;padding-bottom:0cm;padding-left:0.097cm;padding-right:0.191cm;"| There are three '''built-in data types''' in '''Python''' to represent numbers. |
* '''int ''' | * '''int ''' | ||
* '''float '''and | * '''float '''and | ||
* '''complex ''' | * '''complex ''' | ||
− | |||
− | |||
|- | |- | ||
Line 72: | Line 64: | ||
− | Type '''ipython3 '''and press '''Enter''' | + | Type '''ipython3 '''and press '''Enter'''. |
Line 82: | Line 74: | ||
− | Type | + | Type '''a '''''is equal to''''' 13 ''' |
|- | |- | ||
Line 89: | Line 81: | ||
Highlight a | Highlight a | ||
− | | style="background-color:#ffffff;border:0.5pt solid #000001;padding-top:0cm;padding-bottom:0cm;padding-left:0.097cm;padding-right:0.191cm;"| Type | + | | style="background-color:#ffffff;border:0.5pt solid #000001;padding-top:0cm;padding-bottom:0cm;padding-left:0.097cm;padding-right:0.191cm;"| Type '''a''' |
Line 112: | Line 104: | ||
− | These can be explored by typing | + | These can be explored by typing '''a dot '''and then press the '''tab''' key. |
− | Here you can see the list of functions. | + | Here you can see the list of '''functions'''. |
|- | |- | ||
Line 128: | Line 120: | ||
− | Type | + | Type '''b '''''is equal to''''' '''20 times '''9''' |
Line 138: | Line 130: | ||
Highlight the output | Highlight the output | ||
− | | style="background-color:#ffffff;border:0.5pt solid #000001;padding-top:0cm;padding-bottom:0cm;padding-left:0.097cm;padding-right:0.191cm;"| Type''' | + | | style="background-color:#ffffff;border:0.5pt solid #000001;padding-top:0cm;padding-bottom:0cm;padding-left:0.097cm;padding-right:0.191cm;"| Type''' type '''''inside parentheses''''' b''' |
Line 145: | Line 137: | ||
|- | |- | ||
| style="background-color:#ffffff;border:0.5pt solid #000001;padding-top:0cm;padding-bottom:0cm;padding-left:0.097cm;padding-right:0.191cm;"| Type '''p = 3.141592 ''' | | style="background-color:#ffffff;border:0.5pt solid #000001;padding-top:0cm;padding-bottom:0cm;padding-left:0.097cm;padding-right:0.191cm;"| Type '''p = 3.141592 ''' | ||
− | | style="background-color:#ffffff;border:0.5pt solid #000001;padding-top:0cm;padding-bottom:0cm;padding-left:0.097cm;padding-right:0.191cm;"| Next we will see about '''float''' | + | | style="background-color:#ffffff;border:0.5pt solid #000001;padding-top:0cm;padding-bottom:0cm;padding-left:0.097cm;padding-right:0.191cm;"| Next we will see about '''float data type'''. |
− | Type | + | Type '''p '''''is equal to''''' 3.141592 ''' |
|- | |- | ||
Line 155: | Line 147: | ||
Highlight the output | Highlight the output | ||
− | | style="background-color:#ffffff;border:0.5pt solid #000001;padding-top:0cm;padding-bottom:0cm;padding-left:0.097cm;padding-right:0.191cm;"| Type | + | | style="background-color:#ffffff;border:0.5pt solid #000001;padding-top:0cm;padding-bottom:0cm;padding-left:0.097cm;padding-right:0.191cm;"| Type '''type '''''inside parentheses '''''p''' |
Line 171: | Line 163: | ||
Highlight 4.6j | Highlight 4.6j | ||
− | | style="background-color:#ffffff;border:0.5pt solid #000001;padding-top:0cm;padding-bottom:0cm;padding-left:0.097cm;padding-right:0.191cm;"| The last data type in the list is '''complex''' number. | + | | style="background-color:#ffffff;border:0.5pt solid #000001;padding-top:0cm;padding-bottom:0cm;padding-left:0.097cm;padding-right:0.191cm;"| The last '''data type''' in the list is '''complex''' number. |
− | Type | + | Type '''c '''''is equal to''''' 3.2 '''plus '''4.6j ''' |
− | It is just a combination of two floats. | + | It is just a combination of two '''floats'''. |
Line 190: | Line 182: | ||
− | Type | + | Type '''c dot '''and then press the '''tab''' key. |
|- | |- | ||
Line 200: | Line 192: | ||
− | Type | + | Type '''c dot real ''' |
|- | |- | ||
− | | style="background-color:#ffffff;border:0.5pt solid #000001;padding-top:0cm;padding-bottom:0cm;padding-left:0.097cm;padding-right:0.191cm;"| Type | + | | style="background-color:#ffffff;border:0.5pt solid #000001;padding-top:0cm;padding-bottom:0cm;padding-left:0.097cm;padding-right:0.191cm;"| Type '''c.imag''' |
Highlight 3.2 and 4.6 | Highlight 3.2 and 4.6 | ||
− | | style="background-color:#ffffff;border:0.5pt solid #000001;padding-top:0cm;padding-bottom:0cm;padding-left:0.097cm;padding-right:0.191cm;"| Type | + | | style="background-color:#ffffff;border:0.5pt solid #000001;padding-top:0cm;padding-bottom:0cm;padding-left:0.097cm;padding-right:0.191cm;"| Type '''c dot imag''' |
− | '''c | + | '''c dot real''' gives the '''real part''' and '''c dot imag''' gives the '''imaginary part '''of the '''complex''' number. |
|- | |- | ||
| style="background-color:#ffffff;border:0.5pt solid #000001;padding-top:0cm;padding-bottom:0cm;padding-left:0.097cm;padding-right:0.191cm;"| Type, '''abs(c) ''' | | style="background-color:#ffffff;border:0.5pt solid #000001;padding-top:0cm;padding-bottom:0cm;padding-left:0.097cm;padding-right:0.191cm;"| Type, '''abs(c) ''' | ||
− | | style="background-color:#ffffff;border:0.5pt solid #000001;padding-top:0cm;padding-bottom:0cm;padding-left:0.097cm;padding-right:0.191cm;"| We can get the absolute value of c by typing, '''abs '''''inside parentheses '''''c''' | + | | style="background-color:#ffffff;border:0.5pt solid #000001;padding-top:0cm;padding-bottom:0cm;padding-left:0.097cm;padding-right:0.191cm;"| We can get the '''absolute value''' of c by typing, '''abs '''''inside parentheses '''''c''' |
Line 235: | Line 227: | ||
|- | |- | ||
| style="background-color:#ffffff;border:0.5pt solid #000001;padding-top:0cm;padding-bottom:0cm;padding-left:0.097cm;padding-right:0.191cm;"| Type, '''f''' | | style="background-color:#ffffff;border:0.5pt solid #000001;padding-top:0cm;padding-bottom:0cm;padding-left:0.097cm;padding-right:0.191cm;"| Type, '''f''' | ||
− | | style="background-color:#ffffff;border:0.5pt solid #000001;padding-top:0cm;padding-bottom:0cm;padding-left:0.097cm;padding-right:0.191cm;"| To see the value of f, type | + | | style="background-color:#ffffff;border:0.5pt solid #000001;padding-top:0cm;padding-bottom:0cm;padding-left:0.097cm;padding-right:0.191cm;"| To see the value of f, type '''f''' |
|- | |- | ||
Line 242: | Line 234: | ||
Highlight the output | Highlight the output | ||
− | | style="background-color:#ffffff;border:0.5pt solid #000001;padding-top:0cm;padding-bottom:0cm;padding-left:0.097cm;padding-right:0.191cm;"| Type | + | | style="background-color:#ffffff;border:0.5pt solid #000001;padding-top:0cm;padding-bottom:0cm;padding-left:0.097cm;padding-right:0.191cm;"| Type '''f or t''' |
Line 252: | Line 244: | ||
Highlight the output | Highlight the output | ||
− | | style="background-color:#ffffff;border:0.5pt solid #000001;padding-top:0cm;padding-bottom:0cm;padding-left:0.097cm;padding-right:0.191cm;"| Type | + | | style="background-color:#ffffff;border:0.5pt solid #000001;padding-top:0cm;padding-bottom:0cm;padding-left:0.097cm;padding-right:0.191cm;"| Type '''f and t''' |
Line 259: | Line 251: | ||
|- | |- | ||
| style="background-color:#ffffff;border:0.5pt solid #000001;padding-top:0cm;padding-bottom:0cm;padding-left:0.097cm;padding-right:0.191cm;"| Type, '''a=False ''' | | style="background-color:#ffffff;border:0.5pt solid #000001;padding-top:0cm;padding-bottom:0cm;padding-left:0.097cm;padding-right:0.191cm;"| Type, '''a=False ''' | ||
− | | style="background-color:#ffffff;border:0.5pt solid #000001;padding-top:0cm;padding-bottom:0cm;padding-left:0.097cm;padding-right:0.191cm;"| What if you want to apply one '''operator''' before another | + | | style="background-color:#ffffff;border:0.5pt solid #000001;padding-top:0cm;padding-bottom:0cm;padding-left:0.097cm;padding-right:0.191cm;"| What if you want to apply one '''operator''' before another? |
Line 386: | Line 378: | ||
Highlight commands and value of a | Highlight commands and value of a | ||
− | | style="background-color:#ffffff;border:0.5pt solid #000001;padding-top:0cm;padding-bottom:0cm;padding-left:0.097cm;padding-right:0.191cm;"| Type | + | | style="background-color:#ffffff;border:0.5pt solid #000001;padding-top:0cm;padding-bottom:0cm;padding-left:0.097cm;padding-right:0.191cm;"| Type '''a''' |
Line 470: | Line 462: | ||
** Arithmetic Operators and | ** Arithmetic Operators and | ||
** Boolean Operators | ** Boolean Operators | ||
− | |||
− | |||
|- | |- | ||
Line 485: | Line 475: | ||
# What are the three built-in data types in Python to represent numbers? | # What are the three built-in data types in Python to represent numbers? | ||
# Which operator is used to find exponent? | # Which operator is used to find exponent? | ||
− | |||
− | |||
|- | |- | ||
Line 500: | Line 488: | ||
## '''complex ''' | ## '''complex ''' | ||
# Two asterisks are used to find '''exponent'''. | # Two asterisks are used to find '''exponent'''. | ||
− | |||
− | |||
|- | |- |
Revision as of 13:30, 22 May 2018
|
|
Slide containing title | Welcome to the spoken tutorial on "data types and operators". |
Show Slide
Objectives
|
In this tutorial, we will learn about-
|
Show Slide
System Specifications |
To record this tutorial, I am using
|
Show Slide
Pre-requisite slide |
To practise this tutorial,
|
Show Slide
|
There are three built-in data types in Python to represent numbers.
|
[Terminal]
ipython3 |
Let us start ipython.
|
Type, a = 13 | Let's first see about int.
|
Type a
|
Type a
|
Type type(a)
|
To see the type of a, type, type inside parentheses a
|
Type a.<Tab>
|
There are some functions associated with the int data type to manipulate it.
|
Type, b = 99999999999999999999
|
int data type can hold integers of any size.
|
Type type(b)
|
Type type inside parentheses b
|
Type p = 3.141592 | Next we will see about float data type.
|
Type type(p)
|
Type type inside parentheses p
|
Type c = 3.2+4.6j
|
The last data type in the list is complex number.
|
Type c.<Tab>
|
Complex numbers have a lot of functions specific to them.
|
Type, c.real
|
Let us try some of them.
|
Type c.imag
|
Type c dot imag
|
Type, abs(c) | We can get the absolute value of c by typing, abs inside parentheses c
|
Type, t = True | Python also has Boolean as a built-in type.
|
Type, f = not t | Now you can apply different Boolean operations on t.
|
Type, f | To see the value of f, type f |
Type, f or t
|
Type f or t
|
Type, f and t
|
Type f and t
|
Type, a=False | What if you want to apply one operator before another?
|
Type, b=True | Type, b is equal to True |
Type, c=True | Type, c is equal to True |
Type, (a and b) or c
|
Now we will check how precedence changes with parenthesis.
|
Type, a and (b or c) | Now type a and inside parentheses b or c
|
Type, 23 + 74 | Let's now look at some operators available in Python3.
|
Type, 23 - 56 | Minus sign for subtraction.
|
Type, 45*76 | Asterisk sign for multiplication.
|
Type, 384/16 | Backslash sign for division.
|
Type, 87% 6 | Let us move ahead with operators.
|
Type, 7**8 | Two asterisks for an exponent.
|
Type, a=73 | In case, we may want to use the current value of variable in which the result is stored in the expression.
|
Type, a*=34 | Type, a asterisk equal to 34 |
Type, a | To see the value of a, type, a |
Type, a=73 | Again we will assign the same value to a by typing, a is equal to 73 |
Type, a = a*34 | Type, a is equal to a asterisk 34. |
Type, a
|
Type a
|
Show Slide
Exercise 1 |
Pause the video.
|
Show Slide
Solution 1 |
The solution is on your screen.
|
Show Slide
Exercise 2 |
Pause the video.
|
Switch to terminal | Switch to the terminal for the solution. |
Type, 3**0.5 | Type, 3 asterisk asterisk 0.5
|
Type, 3**1/2 | Type, 3 asterisk asterisk 1/2
|
Type, 3**(1/2) | To get the same value, type, 3 asterisk asterisk inside parentheses 1/2
|
Show Slide
Summary slide
|
This brings us to the end of this tutorial.
|
Show Slide
Evaluation
|
Here are some self assessment questions for you to solve
|
Show Slide
|
And the answers,
|
Slide Forum | Please post your timed queries in this forum. |
Slide Fossee Forum | Please post your general queries on Python in this forum. |
Slide Textbook Companion | FOSSEE team coordinates the TBC project. |
Show Slide
Acknowledgement |
Spoken Tutorial Project is funded by NMEICT, MHRD, Govt. of India.
|
Show Slide
Thank You |
This is Priya from IIT Bombay signing off. Thanks for watching. |