Thursday, December 20, 2018

Learn Python from Zero to Hero Part 3

Hello World,
                         If you want to learn Python from Zero to Hero, You are on the right place to learn Python, This Blog will help you to learn Python from Zero to Hero, Let's make learning fun with your smiley face.
So This is the third part of Python Tutorial, If you want to read Part1 or Part2 click the links below.
Learn Python from Zero to Hero Part 1
Learn Python from Zero to Hero Part 2

Variables in Python :
                            If you read little bit about Python than you know about it, that is Python does not support variable type, This make Python easy, You don't have to be confused about the variable types, OMG! which type of variable should i use there ?, Oh! No, I have again  made a variable type mistake in  my code Oh Shit!, But now you will not going to get any kind of variables error in your code, what i am talking about. Because Python gives you the freedom to #CodeYourself,  So let's See How Python use variables ?.

# Variables in Python.
           num = 2
                     print(num)
           name = "Syntaxios Blog"
                     print(name)


Multiple Variables :

# Multiple Variable Initialization.
            name, age = "Syntaxios", "2017"
                    print("Name : "+name+" Age : "+age)

*NOTE : There are few rules about the variables type, that you must have to keep in mind, that is Variable Name should not be start with any number or special character, Python's variable does not support any special character so please avoid the special character in your variable, as we all coder know it's very complicated to assign a meaning variable name #Hahaha, I personally advice you to use camelCase or snake_case writing for variable name.
for Example :
          1num = 2     (Wrong)
          num1 = 2     (Right)
         _num = 2      (Right)
         $num = 2      (Wrong)

You can update your Integer variable at any time, But you can not update String in Python, Because Strings are immutable in Python.

If you want to build Niche Website Templates : click here to Choose best Niche Templates for your business.

String Concatenation in Python :
                                      String concatenation is one of the important thing in programming world, Because this String Concatenation did a good job for programmers, String Concatenation is useful topic for programmers, We need this String Concatenation for make our program compatible. Let's See the Example.

# String Concatenation in Python.
          first_name = "Syntaxios"
                   last_name = "Be Syntaxios"
                              full_name = first_name + last_name      # String Concatenation.
           print("Name : "+full_name)


User Input in Python :
                                    The most important things in each and every programming language the User Input, Sometimes if you want to learn more than a one programming language at the same time, you can learn the more than a one language at a time you should basically learn the basic concept of the programming which you want to learn like User Input, Loops, a little bit about variables etc. you should only focus on the basic concept the particular language. The User Input the most important one also, How to take Input from User in Python ?. Let's See How ?.

# How to take Input from User ?.
           name = input("Enter Your Name ? ")
                     print(" Hello : "+name)                                 # String Concatenation.

Integer Input :

# How to take Integer type Input from User ?.
             num_one = int ( input("Enter the First Number ? ") )
                        num_two = int ( (input("Enter the Second Number ? ") )
                                   add = num_one + num_two
                                                    print("Addition is : "+str(add))   # Here we change the Integer into the String using the str function. You can not concatenate Integer with String that by we change the Integer into the String.

Python always take input or count each and everything as a String, You can not perform string concatenation between the integer or string, String concatenation always perform between the string to string.

Float Input :

    # How to take Float type Input from User ?.
                 num1 = float (input ("Enter float Number ? "))
                              print(num1)


Multiple Input :

# Take Multiple Input in a single line.
            first_name, last_name = input("Enter your full name ? ").split()      # split means space.
                        print("First Name : "+first_name+" Last Name : "+last_name)
or
         name, age = input("Enter your name than coma than age ? ").split(",") # Here we take age as a String input not Integer.
              print("Name : "+name+" Age : "+age)     # Here We did not change age into the string using str function, because we take age input as a string type.

If you want to build Niche Website Templates : click here to Choose best Niche Templates for your business.

At Last Thanks for Reading...
If you have question or doubt about this post don't forget to leave a comment in a Comment Box. and Don't be Cheap to share with others if you like it.

Previous Topic : Part 2.                                                                                                                                   Next Topic : String Formatting.
, , , , , , ,

2 comments: