Thursday, October 24, 2019

Python Course

Course Outline

Session 1: INTRODUCTION TO PYTHON

 - Introduction to python
 - Writing Simple Programs

Session 2: Geometry Basics

- Discuss How Python Program runs
- Types and Operation in python
1. Numbers
2. String
3. List and Tuples
4. Dictionaries
5. Files
6. Statements and Syntax
7. Assignments ,Expressions and Print Statements
8. Conditional Construct
9. Iterative Construct

Session 3:

- Introduction to Functions and Lambda Forms
- Functions and Arguments and Scope
- List Comprehensions
- Generators

Session 4:

- Understanding Modules in Python
- Module Packages
- Package import
- Mixed usage modes
- Introduction to OO Programming in python
- Class coding basic
- OOP and inheritance
- New styles Classes

Session 5:

- Projects
- Query




Friday, October 18, 2019





    Raspberry Pi Introduction


    Raspberry Pi is a small single board computer. By connecting peripherals like Keyboard, mouse, display to the Raspberry Pi, it will act as a mini personal computer.

    Raspberry Pi is popularly used for real time Image/Video Processing, IoT based applications and Robotics applications.

    Raspberry Pi is slower than laptop or desktop but is still a computer which can provide all the expected features or abilities, at a low power consumption.
    Raspberry Pi Foundation officially provides Debian based Raspbian OS. 
    We should use SD card (minimum 8 GB recommended) to store the OS (operating System).
    Raspberry Pi is more than computer as it provides access to the on-chip hardware i.e. GPIOs for developing an application. By accessing GPIO, we can connect devices like LED, motors, sensors, etc and can control them too.
    It has ARM based Broadcom Processor SoC along with on-chip GPU (Graphics Processing Unit).

There are different versions of raspberry pi available as listed below:

  1. Raspberry Pi Zero
  2. Raspberry Pi 1 Model A
  3. Raspberry Pi 1 Model A+
  4. Raspberry Pi 1 Model B
  5. Raspberry Pi 1 Model B+
  6. Raspberry Pi 2 Model B
  7. Raspberry Pi 3 Model B
  8. Raspberry Pi 3 Model B +
  9.  Raspberry Pi 4 Model B.
Operating System of Raspberry Pi:
Raspberry Pi Foundation officially provides Debian based Raspbian OS. Also, they provide  NOOBS is an easy operating system installer which contains Raspbian and LibreELE. It also provides a selection of alternative operating systems which are then downloaded from the internet. We can install several Third-Party versions of OS like Ubuntu, Archlinux, RISC OS, Windows 10 IOT Core, etc.
Raspbian OS is official Operating System available for free to use. This OS is efficiently optimized to use with Raspberry Pi. Raspbian have GUI which includes tools for Browsing, Python programming, office, games, etc.
The OS is not preinstalled on Raspberry Pi , you have to install it by your own.
What size micro SD Card do i need for the Raspberry Pi?
If you're installing the official Raspbian OS you'll need at least an 8GB micro SD card, whereas for
the Raspbian Lite you'll need a minimum of 4 GB.
Raspberry Pi 4 Model B  Specification
  • 1.5GHz 64-bit quad-core ARM Cortex-A72 CPU (ARM v8, BCM2837)
  • 1GB, 2GB, or 4GB RAM (LPDDR4)
  • On-board wireless LAN (dual-band 802.11 b/g/n/ac)
  • On-board Bluetooth 5.0, low-energy (BLE)
  • 2x USB 3.0 ports
  • 2x USB 2.0 ports
  • Gigabit Ethernet
  • Power-over-Ethernet (this will require a PoE HAT)
  • 40-pin GPIO header
  • 2× micro-HDMI ports (up to 4Kp60 supported)
  • H.265 (4Kp60 decode)
  • H.264 (1080p60 decode, 1080p30 encode)
  • OpenGL ES, 3.0 graphics
  • DSI display port
  • CSI camera port
  • Combined 3.5mm analog audio and composite video jack
  • Micro-SD card slot
  • USB-C power
Best Programming Language for Raspberry Pi:
Python Programming Language is widely used among all the programming Languages used for IOT/Raspberry Pi.Python has become one of the most popular programming languages in the open source world. Its interpreter has been packaged and made available in every popular Linux distribution.
How to Link Raspberry Pi with Python?
If you install Raspbian on your Raspberry Pi, There would be default python packages(Python 2
IDLE , Python 3 IDLE) preintalled in that OS.
Getting Started with Raspberry Pi
  • To get started with Raspberry Pi, we have to store required OS on SD card.
  • Now to store OS on SD card we need to install OS on SD card. If you want to know how to install/store OS on SD card you can refer Installing Operating System Image on SD card.
  • Here, we installed the Raspbian OS on SD card.
  • Now, we have an SD card with installed OS and Raspberry Pi Board.
  • Initially to use raspberry Pi we need computer monitor or Digital Display.
  • We can directly connect Raspberry Pi to the Digital Display using HDMI cable.
HDMI Cable
  • But, if we have a computer monitor (VGA Display), then we need an HDMI to VGA converter along with a VGA cable for connecting Raspberry Pi with monitors. HDMI to VGA converter and VGA cable is shown below.

Cable
Now, connect the Raspberry Pi to the Display/monitor and Power-On Raspberry Pi. We will get a Black command window asking for Login and Password as shown below

  • Then, use the following login name and password
                raspberrypi Login: pi
                Password: raspberry
  • This is the default user name and password. You can change the password after the first login.
The above command window can be used to operate Raspberry Pi.
  • To get GUI environment on Raspberry Pi, use below command,                              
 startx

And we will get Home Screen of Raspberry Pi as shown below:
  • On display, there is a symbol of raspberry to the top-left corner of display. After clicking on it, we will get menu as shown below,
  • As we can see, the Raspbian OS has installed Python 2 & 3. It also has different programming IDE like Geany, BlueJ Java IDE, etc. As raspberry pi  has On-chip WiFi, we can connect it to the network and will get access over Internet.
  • We can also change password of “Pi” user.
  • To change password, click on preferences and then select Raspberry Pi Configuration which will provide a pop-up window.
  • Then, click on change password option shown below.
Now, we are quite familiar with Raspberry Pi OS.
How to write Python program on Raspbian OS
  • So, let’s write our First python code on Raspbian and execute it.
  • First Create Empty file and label it with test.py extension.
  • Now write a small program to print “Hello World”
Program
print("Hello world")

After writing the code, open terminal (ctrl+alt+t) to execute it. Then, type following commands for compiling and execution.