Class 1
Author: Jose Miguel Arrieta R.
A computer program is a collection of instructions that performs a specific task when executed by a computer
Designed by Guido van Rossum
Python is a high-level programming language, and its core design philosophy is all about code readability and a syntax which allows programmers to express concepts in a few lines of code.”
Computer Vision
OpenCV library
Download: https://www.anaconda.com/download/.
Spyder is an Integrated Development Environment (IDE).
Console
Spyder is the Scientific PYthon Development EnviRonment
Sublime is an text editor
Notes:
The Jupyter Notebook is an open-source web application that allows you to create and share documents that contain live code, equations, visualizations and narrative text.
Integer <int>
Float <float>
String <str>
Boolean <bool>
>>> type(5)
<type 'int'>
>>> type('str')
<type 'str'>
>>> type(4.6)
<type 'float'>
Variables are used to store information to be referenced and manipulated in a computer program.
a = 5.0
b = 'Hola'
c = 5+6
Input and output (I/O) operators are used to take input and display output.
>>> a = input('Inserte un número: ')
Inserte un número: 3
>>> a
3
>>> print(a)
3
>>> print('Hola')
Hola
Single-line comments
Comments that span multiple lines
# This is a comment
"""
a = input('Inserte un número: ')
a
print(a)
print('Hola')
"""
print('This is not commented')
#Sum Two numbers.
# Request first number from user.
a = float(input("Ingrese un numero: "))
# Request second number to user.
b = float(input("Ingrese otro numero: "))
# Make the sum.
c = a + b
# Show result in screen.
print("\nLa suma de los numeros es: " +str(c))
# Variables:
PI = 3.141592
# Request the radio to the user
r = float(input("Ingrese el radio del circulo: "))
# Calculate perimeter
p = 2 * PI * r
# Calculate area
a = PI * r ** 2
# Muestra los resultados en pantalla
print "El perímetro del circulo es: ", p
print "El área del circulo es: ", a
Algorithm to transform Fahrenheit to Celsius
# Request Fahrenheit degrees to transform into Celsius
f = float(input("Ingrese los grados Fahrenheit:"));
# Make conversion
c = (f - 32.0) * (5.0 / 9.0);
# Show result in screen
print f, " grados Fahrenheit corresponden a ", c, " grados Centígrados"