Python is a popular, high-level programming language. Initially designed by Guido van Rossum in 1991, it was created by Python Software Foundation. It was designed primarily to improve code readability, and its syntax enables programmers to express ideas with fewer lines of code.
The interesting fact of this language is its name, but the truth is this name is not related with the Snake, it is named with the comedy show Monty Python’s Flying Circus.
Introduction with the Python programming
This language is interpreted (bytecode-complied) and dynamic language. The source code is different, you will never find out any parameters, variables, functions or method. This is the reason its codes are flexible and short. Python always tracks all types of values while runtime occurs and flags code that doesn’t execute any sense while it runs.
The best way to see how Python code performs runs the interpreter and then starts typing the code in it.
Do you have a question like, “What happens if I add an int to a list?” then just go to the python interpreter and type the code and see the result like below:
$ python ## Run the Python interpreter Python 2.7.9 (default, Dec 30 2014, 03:41:42) [GCC 4.1.2 20080704 (Red Hat 4.1.2-55)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> a = 6 ## set a variable in this interpreter session >>> a ## entering an expression prints its value 6 >>> a + 2 8 >>> a = 'hi' ## 'a' can hold a string just as well >>> a 'hi' >>> len(a) ## call the len() function on a string 2 >>> a + len(a) ## try something that doesn't work Traceback (most recent call last): File "", line 1, in TypeError: cannot concatenate 'str' and 'int' objects >>> a + str(len(a)) ## probably what you really wanted 'hi2' >>> foo ## try something else that doesn't work Traceback (most recent call last): File "", line 1, in NameError: name 'foo' is not defined >>> ^D ## type CTRL-d to exit (CTRL-z in Windows/DOS terminal)
How to install Python?
Python installation is quite easy, you can install it on any OS like Windows, Mac OS X, Ubuntu, etc. To install the software go to this link.
How to create your first Python project in PyCharm?
- Go to the welcome page of PyCharm, there you will notice “Create New Project”
- Give a suitable Project Name
- Now time to create the first Python Project. So to create a file
- Right-click on the folder name > New> Python File. Write the file name as “HelloWorld” and then hit the Ok.
- Now write down the following code :
- Its time to run the code, so right-click on the HelloWorld.py file or the name you have given to your python file, go to the left slide bar and hit the “Run HelloWorld”.
- You will notice the output at your screen.