SOMETHING PYTHON

“Python is a programming language”, that’s the first thing anyone will probably tell you as soon as you ask, but then, that's not all there is to Python. Python is a programming language and much more!

Python is reputably the easiest of programming languages to learn from several out there. This is because Python was designed for readability, and has some similarities to the English language with easy-to-remember syntaxes that are almost literal in how they are written. It's also worth noting that Python is influenced by mathematics which means that equations can be written almost exactly as they are written with a pen!

Take for instance,

print(9 > 6)

The above statement will output True since Python executed the program and determined that nine is greater than six.

Also, consider the program,

print(“Hello, Anyone?”)

The above statement will output Hello, Anyone after running the program since the program simply commanded to print the statement Hello, Anyone.

Python also has a few convenient functions that help make writing a program much easier. One such function is the variable. Imagine writing a thousand-line program and repeating a word (or phrase)about 50 times throughout the program. Now also imagine that the said word (or phrase) was a mistake and you need to change it to something else entirely. It would be a truly herculean task to carefully search through a thousand lines to make such corrections and there's no guarantee that you'll get it done on the first try. This is where variables come in. A variable is simply a container in Python for storing data. Variables make it much easier to write codes and then come back to make changes at a later time when needed as many times as you want. For example,

print(“John is an old fellow,”)

print(“he is 50 years old.”)

print(“He really likes the name, John,”)

print(“but does not like being 50.”)

The above program will output,

John is an old fellow,

he is 50 years old.

He really likes the name, John,

but does not like being 50.

The above is a simple 4-line program but it already takes 4 actions to make corrections. Hence to prevent this, we simply declare a variable and assign a value to it. Since Python does not have a function to declare a variable, this is even easier. Using the same example we have that;

x = John

y = 50

print(x + “is an old fellow,”)

print(“he is ” + y + “ years old.”)

print(“He really likes the name, ” + x + “,”)

print(“but does not like being ” + y “.”)

The above program will output,

John is an old fellow,

he is 50 years old.

He really likes the name, John,

but does not like being 50.

And when we make changes to the variable it simply becomes;

x = Sam

y = 35

print(x + “is an old fellow,”)

print(“he is ” + y + “ years old.”)

print(“He really likes the name, ” + x + “,”)

print(“but does not like being ” + y “.”)

The above program will output,

Sam is an old fellow,

he is 35years old.

He really likes the name, Sam,

but does not like being 35.

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store