Python-3.4.3/C3/Basic-datatypes-and-operators/English
|
|
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 | slash 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. |