Python's History, basic syntax and if, else, elif statements.

Sep 8, 2022Β·

4 min read

Play this article

Hello everyone! My name is Amena.πŸ‘‹


About Python:

Python is an Interpreted, Object Oriented High level programming language that uses Dynamic Semantics and it's so easy to use python!! In late 1980's Guido Van Rossum had Invented Python Language!! When Guido Van Rossum was making this language he saw a "Monty Python Circus" named show, and he decided to name this language "Python". He named this language as Python because he want a unique and short name. Till 12th of July, 2018 he had taken a responsibility. As a lead Developer it is so appreciable and hard-work!🌎 But after 2018 Guido Van Rossum had to announce his permanent vacation, Genuinely he was the legend!β™₯

After the long journey, python is one of the most preferred language. In the 1990s, the development of the Python language was done in very spectacular. And in the year 2000 Python 2 was released, after this in the year 2008 Python 3 was released.🐍

Along with Python 3, a utility called "2to3" has been released that will help you convert your Python 2 code to Python 3. Even after the popularity of python many people use python 2.7, because they were more comfortable with the syntax of python 2.7. Also in python 3 there were so many changes compared with python 2.7. The end of python 2.7 was announced in 2015, means it was compulsory to use python 3 only.πŸ—¨

So this was history about python now let's come to the language and syntax!!πŸ˜€

So now let's go!!πŸ—¨

  • For commenting(It'll not output anything!) any string hashtag (#) is used, LIKE THISπŸ‘‡
    #This is a comment.
  • In python there is a function called print it helps to output any string (also you can print anything in this), LIKE THISπŸ‘‡
print("Hello Coders")
  • In python you can you use arithmetic operators(+, -, /, *) LIKE THISπŸ‘‡
    print(6 + 6)
    print(6 - 6)
    print(6 / 6)
    print(6 * 6)
  • To declare variables you can simply type variable = value. LIKE THISπŸ‘‡
    variable = "Hello"
    amena = 1
  • To store one or more values you can use list with square brackets ([])
    mylist = ["Burger", "Pizza", "Sandwich", "Hotdog"]
    amena_likes = ["Badminton", "Cricket", "Football"]
    These were something about python syntaxπŸ‘†

Now let's come to the If, else and elif statements in pythonπŸ—¨

So, I am here because of If,else and elif statements in Python and I will try my 100% to teach you all. And also personally if, else and elif statements my favorite.

So Let's Start First let's talk about if statements in Python!!

Basically if statements are like: IF YOU'LL GIVE ME 10 BUCKS THEN I'LL GIVE YOU CHOCOLATES.

Okay hopefully that went well!! So lemme give you some examples of if statements!!

money = int(input("For chocolates pay 10 bucks, Pay here: " ))
if money == 10:
  print("Chocolates are yours🍫🍫🍫")

Output πŸ‘‡

For chocolates pay 10 bucks, Pay here: 10
Chocolates are yours🍫🍫🍫

So there is one thing that you must know in python, that from colon (:) and then space (indentation), Python understands that we are inside of the if block. And hence it executes what is inside if, if the condition provided is true.

So hopefully you are done by if statements, and you have cracked one of the statements!!πŸ˜‰ Congrats!!πŸ₯³

So now lets come to else statements in Python!
Now for those who are beginners, they would be wondering that what are else statements?🀷

So let's go!😎

Lemme give you one example for else statements!!

money = int(input("For Fries pay 3 bucks, Pay here: "))
if money >= 3:
  print("Fries are yours!🍟")
  print("Not enough money.")


For Fries pay 3 bucks, Pay here: 3
Fries are yours!🍟

But if anyone is not having enough moneyπŸ‘‡

For Fries pay 3 bucks, Pay here: 2
Not enough money.

Basically It's a rule in python that there should not be any kind of condition after else statements like we must write colon after else statements!! Like this: else:

So, Hopefully you are done with else statements also!! Wow! It's Dope!!πŸ‘πŸ‘

Let's move on to the next one that is elif statements.πŸ˜‰

Basically elif statements are the mixture of else + if = elif.


food = input("ice cream or pastry: ")
if food.lower() == "ice cream":
elif food.lower() == "pastry":
elif food.lower() == "ice cream and pastry":

So these were the If, else and elif statementsπŸ‘†

Now I am gonna recommend some channels to you guys for learning coding!!πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’»

  1. Scrimba

  2. sololearn

  3. ProgrammingWithHarry[IN engish]

  4. Code with Harry.(IN hindi)

  5. Telusko

  6. codeSTACKr

  7. The net ninja

  8. Max programming (My brother's channel...)

  9. Code Arena (My channel)

So, that's all guys!!

I wish you all the very best for your future!β™₯

Love youu all!🌎