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

cadurseg_Programacion_II_Clases

The document outlines a Python programming course taught by Karen Andrea Fonseca Estupiñan, covering topics such as programming fundamentals, object-oriented programming, and applications in machine learning and deep learning. It includes details on assessment methods, class structure, and various Python concepts like variables, data types, and operators. The document also provides examples of Python methods and operators, emphasizing the importance of understanding these foundational elements in programming.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views

cadurseg_Programacion_II_Clases

The document outlines a Python programming course taught by Karen Andrea Fonseca Estupiñan, covering topics such as programming fundamentals, object-oriented programming, and applications in machine learning and deep learning. It includes details on assessment methods, class structure, and various Python concepts like variables, data types, and operators. The document also provides examples of Python methods and operators, emphasizing the importance of understanding these foundational elements in programming.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 28

Welcom

e!

PROGRAMACION
DE
COMPUTADORES
2024-1
II
Who is the teacher?
Karen Andrea Fonseca Estupiñan “PC2:-------”

UIS Electronic Engineer [email protected]

Master's student in electronic engineering Laboratorios Pesados 336


Grupo de Investigación HDSP
PhD student in electronic engineering

What is the purpose of


programming in Python?
What do these publications have in
common?
Here we are going to learn that!

Pytho ML and Deep Learning


n
What topics?
1. Python Programming Fundamentals

• Variables, types y conversions.


• Operators
• Lists
• Dictionaries, sets y tuples
• If, switch, try, except
• While, for
• Functions
What topics?
2. Object Oriented Programming using Python

• Classes
• Attributes
• Methods
• Constructors
• Overload of operators
• Polymorphism
• Import Create modules
What topics?
3. Applications
• Array programming
• Numpy
• ML basics with classes
• Deep Learning introduction
Scores
1. First exam 25%

2. Second exam 25%

4. Workshops and quizzes, participation 25%

5. Project 25%
Note
The exams will consist of two sections, verbal and written.

Some quizzes will be notified, others will be surprise.

The class is always open to questions. Ask if you do not


understand. The subject is cumulative.

Visual Studio Code and Google Colab.


Question
s?
Ask me if you want more
information

Question
s?

Spoiler: Variables, types and conversions

https://www.w3schools.com/python/
default.asp
Variables, types and
conversions x = "Hello World"
x = 20
str
int
x = 20.5 float
x = 1j complex
x = ["apple", "banana", "cherry"] list

x = ("apple", "banana", "cherry") tuple

You can use type() to print x = range(6) range

the type of variable. x = {"name" : "John", "age" : 36} dict

x = {"apple", "banana", "cherry"} set

x = frozenset({"apple", "banana", "cherry"}) frozenset

x = True bool
x = b"Hello" bytes
x = bytearray(5) bytearray
x = memoryview(bytes(5)) memoryview
x = None NoneType
Variables, types and
conversions x = str("Hello World")
x = int(20)
str
int
x = float(20.5) float
x = complex(1j) complex
x = list(("apple", "banana", "cherry")) list

x = tuple(("apple", "banana", "cherry")) tuple

Also, you can set a specific x = range(6) range

data type x = dict(name="John", age=36) dict

x = set(("apple", "banana", "cherry")) set

x = frozenset(("apple", "banana", "cherry")) frozenset

x = bool(5) bool
x = bytes(5) bytes
x = bytearray(5) bytearray
x = memoryview(bytes(5)) memoryview
Variables, types and
conversions
Code Result

\' Single Quote

\\ Backslash

\n New Line
Escape Characters \r Carriage Return

\t Tab

\b Backspace

\f Form Feed

\ooo Octal value

\xhh Hex value


Variables, types and
conversions
Method Description
capitalize() Converts the first character to upper case
casefold() Converts string into lower case
center() Returns a centered string
count() Returns the number of times a specified value occurs
in a string
encode() Returns an encoded version of the string
endswith() Returns true if the string ends with the specified
value
String methods expandtabs() Sets the tab size of the string
find() Searches the string for a specified value and returns
the position of where it was found
format() Formats specified values in a string
format_map() Formats specified values in a string
index() Searches the string for a specified value and returns
the position of where it was found
isalnum() Returns True if all characters in the string are
alphanumeric
isalpha() Returns True if all characters in the string are in the
alphabet
isascii() Returns True if all characters in the string are ascii
characters
istitle() Returns True if the string follows the rules of a title
Variables, types and
conversions
Method Description
isupper() Returns True if all characters in the string are upper case
join() Joins the elements of an iterable to the end of the string
ljust() Returns a left justified version of the string
lower() Converts a string into lower case
lstrip() Returns a left trim version of the string
maketrans() Returns a translation table to be used in translations
partition() Returns a tuple where the string is parted into three parts
replace() Returns a string where a specified value is replaced with a
String methods specified value
rfind() Searches the string for a specified value and returns the last
position of where it was found
rindex() Searches the string for a specified value and returns the last
position of where it was found
rjust() Returns a right justified version of the string
rpartition() Returns a tuple where the string is parted into three parts
rsplit() Splits the string at the specified separator, and returns a list
rstrip() Returns a right trim version of the string
split() Splits the string at the specified separator, and returns a list
splitlines() Splits the string at line breaks and returns a list
Variables, types and
conversions
Method Description
startswith() Returns true if the string starts with the specified value
strip() Returns a trimmed version of the string
swapcase() Swaps cases, lower case becomes upper case and vice
String methods versa
title() Converts the first character of each word to upper case
translate() Returns a translated string
upper() Converts a string into upper case
zfill() Fills the string with a specified number of 0 values at the
beginning
Arithmetic Operators
Arithmetic operators are used with numeric values to perform common mathematical operations:

Operator Name Example


+ Addition x+y
- Subtraction x-y
* Multiplication x*y
/ Division x/y
% Modulus x%y
** Exponentiation x ** y
// Floor division x // y
Assignment Operators
Operator Example Same As
= x=5 x=5
+= x += 3 x=x+3
-= x -= 3 x=x-3
*= x *= 3 x=x*3
/= x /= 3 x=x/3
Assignment operators are used
%= x %= 3 x=x%3
to assign values to variables.
//= x //= 3 x = x // 3
**= x **= 3 x = x ** 3
&= x &= 3 x=x&3
|= x |= 3 x=x|3
^= x ^= 3 x=x^3
>>= x >>= 3 x = x >> 3
<<= x <<= 3 x = x << 3
Comparison Operators
Comparison operators are used to compare two values:

Operator Name Example


== Equal x == y
!= Not equal x != y
> Greater than x>y
< Less than x<y
>= Greater than or equal to x >= y
<= Less than or equal to x <= y
Logical Operators
Logical operators are used to combine conditional statements:

Operator Description Example


and Returns True if both statements are true x < 5 and x < 10
or Returns True if one of the statements is x < 5 or x < 4
true
not Reverse the result, returns False if the not(x < 5 and x < 10)
result is true
Operator Precedence
Operator Description

() Parentheses
** Exponentiation
+x -x ~x Unary plus, unary minus, and bitwise NOT
* / // % Multiplication, division, floor division, and
modulus

+ - Addition and subtraction


Operator precedence
<< >> Bitwise left and right shifts
describes the order in
& Bitwise AND
which operations are
performed. ^ Bitwise XOR
| Bitwise OR
== != > >= < <= is is not in not in Comparisons, identity, and membership
operators

not Logical NOT


and AND
or OR
List Methods
Method Description
append() Adds an element at the end of the list
clear() Removes all the elements from the list
copy() Returns a copy of the list
count() Returns the number of elements with the specified value

extend() Add the elements of a list (or any iterable), to the end of the
current list
index() Returns the index of the first element with the specified
value
insert() Adds an element at the specified position
pop() Removes the element at the specified position
remove() Removes the item with the specified value
reverse() Reverses the order of the list
sort() Sorts the list
Tuple Methods

Method Description
count() Returns the number of times a specified value occurs in a tuple
index() Searches the tuple for a specified value and returns the position of where it
was found
Set Methods
Method Description
add() Adds an element to the set
clear() Removes all the elements from the set
copy() Returns a copy of the set
difference() Returns a set containing the difference between two or more sets
difference_update() Removes the items in this set that are also included in another, specified set

discard() Remove the specified item


intersection() Returns a set, that is the intersection of two other sets
intersection_update() Removes the items in this set that are not present in other, specified set(s)
isdisjoint() Returns whether two sets have a intersection or not
issubset() Returns whether another set contains this set or not
issuperset() Returns whether this set contains another set or not
pop() Removes an element from the set
remove() Removes the specified element
symmetric_difference() Returns a set with the symmetric differences of two sets
symmetric_difference_update() inserts the symmetric differences from this set and another
union() Return a set containing the union of sets
update() Update the set with the union of this set and others
Dictionary Methods
Method Description
clear() Removes all the elements from the dictionary
copy() Returns a copy of the dictionary
fromkeys() Returns a dictionary with the specified keys and value
get() Returns the value of the specified key
items() Returns a list containing a tuple for each key value pair
keys() Returns a list containing the dictionary's keys
pop() Removes the element with the specified key
popitem() Removes the last inserted key-value pair
setdefault() Returns the value of the specified key. If the key does not exist: insert the key, with the specified value

update() Updates the dictionary with the specified key-value pairs


values() Returns a list of all the values in the dictionary
Operators overloading
Operators overloading
Operators overloading

You might also like