Software DevelopmentA Beginner's Guide To Python3 Bootcamp

A Beginner’s Guide To Python3 Bootcamp

Python is the fastest growing language in terms of number of developers who are using it, the number of libraries it has, number of companies who are using it and in terms of areas to be implemented. If we talk about machine learning, GUI, software development, web development, it can be used everywhere and that’s why is it also called a general purpose language. It is a programming language which is interpreted, object-oriented high-level language. It also supports procedure-oriented programming depending upon the purpose you can use it the way you want. It came in 1989 which is the easiest programming language till now way much easier than JAVA, C++ or any other language. Reddit is purely written in python and there are many companies which are using python as a supportive language or as a main language like Google, NASA, etc. Guido Van Rossum has written this language. It is one of the easiest languages to learn.

Why Python3?

Why Python3

Python3 is, on the whole, is not better than Python2 yet they have less support documentation and libraries. The entire good thing in Python 3 has been ported back to Python2. Always new updations are done in the languages so it is constantly a process of growing. Back in 2008, the creator of Python was a bit unhappy with some of the really important architectural decisions that were made earlier. So he decided to overhaul Python and decided to release Python3. It is not backward compatible. So usually when you have a programming language and changes are made it’s made incrementally and it’s made in a way that old code can still run. So old javascript written five years ago if you try to run it now there won’t be any problems. But with Python3 the opposite was true. So the all the existing users existing companies that were built on Python2 their code and libraries everything they have done up to that point would not work if they were run with python3 and because of that still to this day Python 2.X is still commonly used. Python3 is now very common but that wasn’t always the case because it’s taken a while for the companies and for libraries to fully support Python3. So it is difficult for a newbie to decide which version to choose. Python3 is absolutely the best way to go as the situation has improved on. Python 2.7 is going to be retired too soon.

Python 2.7

Where should you start?

start python

Installing Python

You can write a Python code anywhere even on a notepad but run a program we need to install an interpreter which is a Python interpreter. To install Python from the official website of Python which looks like something below:

Installing Python

On installing the setup the Python window will look like something below

Python window

Intro to Lists and Objectives

A List is a collection or grouping of items and those items could be string, float, integers. Boolean values or any other lists. It is a way of combining data into one data. Let’s say we want to make an app that has a shopping cart feature. So a user could add items to a shopping cart and keep track of those items. These are called arrays and in Python, these are called lists.

Lists and Objectives

Behind the scenes, they are all stored in the exact same list.

Swapping values in the list

Swapping values

When do you need to swap – When you are shuffling things, sorting we are not making a new list.

Methods

We’ve already seen a few examples of methods when learning about Object and Data Structure Types in Python. Methods are essentially functions built into objects. Later on, in the course, we will learn about how to create our own objects and methods using Object Oriented Programming (OOP) and classes.
Methods perform specific actions on an object and can also take arguments, just like a function. This lecture will serve as just a brief introduction to methods and get you thinking about overall design methods that we will touch back upon when we reach OOP in the course.

Methods are in the form:

object.method(arg1,arg2,etc...)

Let’s take a quick look at what an example of the various methods a list has:

In [1]:
# Create a simple list
lst = [1,2,3,4,5]

Fortunately, with iPython and the Jupyter Notebook, we can quickly see all the possible methods using the tab key. The methods for a list are:

  • append
  • count
  • extend
  • insert
  • pop
  • remove
  • reverse
  • sort
    Let’s try out a few of them:
    append() allows us to add elements to the end of a list:
In [2]:
lst.append(6)
In [3]:
lst
Out[3]:
[1, 2, 3, 4, 5, 6]

Great! Now, how about count()? The count() method will count the number of occurrences of an element in a list.

In [4]:
# Check how many times 2 shows up in the list
lst.count(2)
Out[4]:
1

You can always use Shift+Tab in the Jupyter Notebook to get more help about the method. In general Python you can use the help() function:

In [5]:
help(lst.count)

A SIMPLE CODE TO WRITE PYTHON3

CODE TO WRITE PYTHON3

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Exclusive content

- Advertisement -

Latest article

21,501FansLike
4,106FollowersFollow
106,000SubscribersSubscribe

More article

- Advertisement -