Are you programmer? NO. Doesn’t matter we will start from the very beginning to clear your basic concepts about Python and it’s Syntax.
I was in 2nd year of my university when i decided now i have to get my hand dirty with python but i didn’t find some proper mentor who help me where to start to become a python expert.So i started on my own but i take a long time to clear my concepts because i was feeling shy at that time that if someone help me it’s good otherwise let it go.Then with time to time i realize that you could learn and clear your concepts about each and every thing when you have access to “Google Ustad” .Ustad is literally a Urdu word use for Teacher. But if you struggle for something then it definitely become worthy. For what i have i don’t want to let anyone struggle that much when you have the proper Road-map to follow.
So now it’s your turn to get your hand dirty with python by clearing the some basic concepts of python.I Would share my knowledge about everything that i have learn in python from the very basic towards advancement.Once you know proper syntax of the language then further all depend upon your mind to make logic and program according to that. Building logic is kind of an art every program can be written in different ways. I believe that if some problem is given to the class of ten students and each one have different thinking from each other then that problem can have ten possible solutions as well.
So newbies to every language take start from very basics like input output syntax. So, we would also take start from there.
variable1=input("Enter your Name :")
Enter your Name :Adnan khan
As you could see in above Figure we declare as variable with the name of variable1 and passes simple the input to it. You can take input in python by simple calling the input function. Here you should remember one thing that every single input is taken as string by default. We would briefly discuss string Datatype later on.Now if you want to take some other type of input let’s see how you would take that
variable_int=int(input("Enter the number of your wish :"))
Enter the number of your wish :15
In the above code you could see we have taken the input from the user in the form of integer.Similarly you can take all other types of input from the user.We can check the datatype of the variable simply by using the the function type( ).The purpose of type( ) function is to return the type of the object.So that was all about input function.
Now lets discuss how to get output from the program. Python syntax is easy to understandable by the human being. For output statement we simply use the Print( ) statement.
You can notice the print statement it print the statement inside parenthesis. You could whatever you want by simply write inside parenthesis as well as in quotation marks. See Figure 2 as well where we used print statement to print the variable_int we have declared.So that was all about input and output syntax.
Data Types :
You don’t know what is data types? So it isn’t a great problem we would discuss each and every data type in detail and you would be able to clear your concepts about that.
It often called as integers or int, it contain real numbers without decimals like 1,9,110 etc .Integer can be of any length.It’s the simplest way to define Integer data type.
The float is similar to integer but the main difference among them is that float contain decimals like 1.5,2.3,65.7 etc.Float is accurate only to 15 decimal points.
Decimal is similar to float data type but float has accuracy only limited to 15 decimal points.So, sometimes it causes an error how it create an error let me show through code
According to human mind calculation these both numbers are equal but python rejects it. As computers only understand binary(0 or 1) and floating-points store in memory in binary form and these numbers didn’t get properly stored that’s why it rejects.
We generally use Decimal in the following cases.
- When we are making applications that need exact decimal representation.
- When we want to control the level of precision required.
Complex data type is very rarely use in python. If you have read the basic mathematics in school life you get across with term something like this 3+5j. It contain two values one is real where other is imaginary.The value with term “j” is imaginary value.
So that was all about Input-Output and datatypes in python.It was the first day to take a start I will try on daily bases to discuss little bit of my knowledge what i have gained so far. I’m not pro but i believe in that with sharing your knowledge with someone it would definitely beneficial for me as well. I will share some free resources where you could learn about python free of cost.
Introduction to Python
Master the basics of data analysis in Python. Expand your skillset by learning scientific computing with numpy.
Introduction to Python for Data Science (2016-11-10)
Python is a free, open-source programming language that has gained a lot of popularity in recent years. At this meetup…
If you have the stamina of reading books then you should follow the book where you would learn a lot by solving some basic examples.
Python-By-Examples by Nichola Lacey
You can download it from google free of cost.Now go for it and get your hands dirty. Solve as many as examples you can.
· Clear your concept about problem.
· Find possible solution for it.
· Don’t irritate over errors. From these small errors you would learn a lot.
· Try to dry run your code and check the output.
· Teach others to strong your own base.
Give your valuable feedback.it would be great for me to gain some knowledge from you guys.