0% found this document useful (0 votes)
28 views

0 - Python Programming

Uploaded by

valer93979
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views

0 - Python Programming

Uploaded by

valer93979
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

0 - Welcome to Introduction to Engineering Programming

Installing Python on your computer


Option 1: Python interpreter & IDE
• Go to https://python.org/downloads

• Click on the Download Python 3.xx.xx button near the top of the page

• An installer will be downloaded to your computer

• Run the installer and follow the prompts to install Python on your computer

• It is recommended that you also install an IDE, preferably Microsoft Visual Studio Code.

• To do so, go to https://code.visualstudio.com/download

• Download the appropriate installer for your operating system

• Follow the prompts of the installer to set it up on your computer.

• You are now ready to work with Python on your computer!

Option 2: Python's Scientific Computing package


Initial Anaconda/Spyder IDE installation/setup
Install Anaconda on your computer. Ensure Spyder and Jupyter is properly setup and working. You can confirm by running the customary first program in a new programming language.

On Jupyter, Then click Run or press Ctrl+Enter

Congratulations, you're now a Python programmer! It is clear that there's significantly less code to write to print out a statement in Python than in several other languages like C or C++!
On Spyder,

Then press Enter

Option 3: Python in the browser


You can also run Python in your browser on any device: personal computers, tablets, as well as mobile phones

• Go to https://colab.research.google.com/

• Login to with your Google account.

• Click on New Notebook and start writing Python code!


What is a computer program
A computer program is a set of instructions to a computer which is typically designed to perform a specified task.

Note: It is possible, and even customary to design the set of steps that are involved in performing a specific task before implementing the steps in a programming language. This concerns the design of algorithms. An
algorithm is a set of commands that are followed for a computer to perform a specific task.

Programming languages
A computer program is written using a computer programming language. So a computer programming language is simply a language/system of notations for writing computer programs.

Examples of programming languages?

Classification of programming languages Programming languages can be classified into low-level programming languages and high-level programming languages .

A low-level programming language is programming language is used to write computer programs that the target computer's processor can understand. Low-level languages are also known as machine language. The
drawback of machine code/language is that they are written specifically for a particular computer processor and will not work on any other type of computer processor.

Assembly language is also considered to be low-level. Here, some abstraction is possible and groups of machine code instructions can be invoked with a single command in assembly code. Assemblers are used to
convert assembly-language programs to machine language.

With the advent of assembly languages, the use of computers increased rapidly. However, programmers still had to use numerous instructions to accomplish even simple tasks.

High-level languages were developed in which single statements could accomplish substantial tasks. High-level language allow you to write instructions that look almost like everyday English and contain common
mathematical notations. It is important to note that high-level languages still needs to be converted to machine code for the computer to understand them. Depending on the language, there are two ways this is
achieved:

• Some languages use translator programs called compilers to convert high-level language code into machine language. Typically, for languages that use compilers, the translation to machine code is done
before the code is run. Such languages are referred to as compiled languages. Example of compiled languages include: Rust, C, C++, C#, Go, etc.
• Compiling a large high-level language program into machine language can take considerable computer time. Some languages support interpreters, which execute high-level language programs directly (on a line-
by-line basis). Interpreters avoid compilation delays but your code runs slower than compiled programs. Languages that support interpreters are called interpreted languages. Examples of interpreted languages
include: Python, R, JavaScript, etc.

The Basics of Python (Student's part)


At this point, we're ready to begin to study the basics of Python.

• What is Python?
• Coding style and language ethos

What is Python?
Python is a general-purpose programming language that supports many programming paradigms, such as object-oriented programming, functional programming, and procedural programming. Python is an interpreted
language, which means that programs written in it do not need to be compiled before running, as is common in C and C++.

Question: What are programming paradigms?

Python is the dominant language in the field of artificial intelligence and machine learning. It is also very popular in other fields of computing, such as data analytics, data science, web development, and increasingly in
Python is the dominant language in the field of artificial intelligence and machine learning. It is also very popular in other fields of computing, such as data analytics, data science, web development, and increasingly in
embedded systems development (microcontrollers use a flavor of the language known as MicroPython). A solid understanding of Python would be very beneficial to an engineer looking to explore several exciting
emerging fields in technology. The instructor recommends that students continue striving to gain mastery of the language beyond the scope of this course.

The Next Class


Students taking this course will be expected to attend the next class with their computers, ready to program in Python

Welcome to ECE 272!

In [ ]: import this

The Zen of Python, by Tim Peters

Beautiful is better than ugly.


Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one-- and preferably only one --obvious way to do it.
Although that way may not be obvious at first unless you're Dutch.
Now is better than never.
Although never is often better than *right* now.
If the implementation is hard to explain, it's a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea -- let's do more of those!

Lecture Schedule
Tuesdays: 10AM-12PM

Thursdays: 11AM-12PM

You might also like