Python Programming [Part-02] :: Variable and String and Data Input.
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.
Thank you sir for giving the tutorial. It will help all beginner programmers.
Python is a powerful high-level, object-oriented programming language created by Guido van Rossum.
It has simple easy-to-use syntax, making it the perfect language for someone trying to learn computer programming for the first time.It has wide range of applications from Web development
yes
This post has received a 0.15 % upvote from @drotto thanks to: @dihan.
Congratulations! This post has been upvoted from the communal account, @minnowsupport, by Reja83 from the Minnow Support Project. It's a witness project run by aggroed, ausbitbank, teamsteem, theprophet0, someguy123, neoxian, followbtcnews, and netuoso. The goal is to help Steemit grow by supporting Minnows. Please find us at the Peace, Abundance, and Liberty Network (PALnet) Discord Channel. It's a completely public and open space to all members of the Steemit community who voluntarily choose to be there.
If you would like to delegate to the Minnow Support Project you can do so by clicking on the following links: 50SP, 100SP, 250SP, 500SP, 1000SP, 5000SP.
Be sure to leave at least 50SP undelegated on your account.
Greetings! I am a minnow exclusive bot that gives a 5X upvote! I recommend this amazing guide on how to be a steemit rockstar! I was made by @EarthNation to make Steemit easier and more rewarding for minnows.