Hope to be good.
I appeared on Python 's second part.
If you didn't read my previous post click here
In the middle
Today I will discuss the variables and string
and data inputs. Before that we had
an overview of the old issues . Like
the previous episode, we print something down below.
Write all in Python's New Window:
1 print (22/7)
2 print (10 * 3)
3 print ("your name is .........")
4 print ("22/7 is",
22/7 ) 5 print ("11 * 6 is", 11 * 6)
and see these results by running them.
Variable and string:
Variable is an
object that stores different data. And the string is the
data that is stored in the variable.
If you look down, the matter will be more clear.
1 a = 12
2 b = 25
here a and b are two variable. And 12 and 25 are two strings
that are stored in the variable.
Now write
1 print (a)
2 print (b)
Now see Python a, b instead of b, a value of b or
print string.
Now type the following program:
1 a = 5
2 b = 10
3 c = a + b
4 print ("a + b =", c)
Here I have given a, b and a variable c
which add value to it. Then I
asked to print that c variable.
Write down the code and
print the value of a + b in Python c .
You can also write:
1 a = 5
2 b = 10
3 c = a + b
4 print (c)
If you want to take a number as a string,
it will be written as before. But to
pick any character, it
must be written in "" . Eg:
1 a = "apple" 2b
= "orange"
3 print (a)
4 print (a + b)
AppleoRange has been printed on the watch screen.
Now type:
1 a = "apple" 2b
= "orange"
3 print (a * 5)
5 times apple printed.
Python Input: The process that
is stored with information from the user with the help of that
input is called input.
Python input is three types.
- Any character input, such as someone's name,
email etc.
Method: input ("enter your name here:") (Only for the
alphabets) - Any number (excluding decimal). Any
password which is made up of numbers only.
Method: int (input ("Enter your password here:")) - Any number with dynamic.
Method: float (input ("Enter your number:"))
Now let us create a little fun program
that
will find a man's death day according to your order:
1 print ("Lets know when you will die")
2 n = input ("Enter your name here:")
3 a = float ( input ("Enter your age here:")
4 c = 2075 - a
5 print ("You will die at:", c, n)
6 input ("Please give your feedback:")
Save it with .py Let's
double click on it to run .
Give inputs to the data well and see it as your death.
Explanation: Here we primarily print ("Lets know
when you will die") to give the user an idea
about the program
.
Then we
know the username by n variable .
A user has learned the age of a variable
.
Now we have created a variable called c,
which we have ordered
to subtract the value of a variable from 2075. And
we printed it as n the death day. That is, our program will print its death date ,
because the age of the person is not inputable
, or by subtracting that input from 2075
.
Then again we
wanted to have user feedback and input through input .
In this way, you have to create more
small programs like yourself and continue to practice.
To this day. If anyone
can not understand anything then tell the comment.