Keywords in python.
Keywords are generally reserved words-meaning you can not use these words as a variable(we will come to it in a moment). Examples are
for
while
do
if,elif,else
pass
continue
break
assert
and all the operators.etc.,
Input/Output.
Lets practice this in jupyter notebook.
Open jupyter, on the top right you will see new, click on that and click python3.
Once you are done, a new project will be opened.
When you want to enter input, Let's say we have to add two numbers, we have to get two numbers as input.
For that type,
variable_name=int(input())
Here input() function gets the input from the user
int denotes the type of input(here it is integer)
= operator assigns the integer input to the variable in left.
example
a=int(input())
Here, I am getting two integers as input.
Click Shift+enter to execute the line.
It will ask for inputs.
Enter the numbers followed by Shift+enter
Then we perform addition operation and save the result to c.
Now, the value of c will be 20.
To display the output, we use print() function.
Points to remember
- Here, a,b,c are called variables.We cannot use keywords for these variables.
- The program runs in the order in which you run the lines in jupyter notebook.
- String is a non-mutable datatype(you cannot alter the values).
- other data types are list,tuple,dictionaries.
IMPORTANT: Jupyter notebook executes line by line instructions.
We will talk about other datatypes in the following posts.
If you have come this far,GREAT JOB!
Thank you!
Thank you 😊. I would like to like to know more about split and strip methods in the following posts if u can 😅
ReplyDeleteSure!will post soon with the video in this week along with detailed explanations of datatypes
Delete