Skip to content
Snippets Groups Projects
Commit 0413c87a authored by chloebt's avatar chloebt
Browse files

update 2023-2024

parent 089cc82a
No related branches found
No related tags found
No related merge requests found
Showing
with 222 additions and 15937 deletions
File deleted
......@@ -2,18 +2,9 @@
Contact: chloe.braud@irit.fr
Lien pour l'évaluation du cours : https://forms.gle/2T25fgaG5698sXyP8
Current schedule:
* 24.11 9h30-12h30 : ML reminder
* 28.11 13h30-15h30 : ML reminder
* Basics of OOP: https://colab.research.google.com/drive/1oPha9EekRpq5Uvm227xBlumZOZ3f8UNF?usp=sharing
* To load the notebook: TP1 Sentiment analysis with ScikitLearn [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/drive/1IOXm9X6BEJgkTjEd_kh_OYPnK1OvwD7l?usp=sharing)
* **You'll need to save a copy to your google drive or a notebook on your PC**
* TP2 [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/drive/1qZ7tQcqNXe4bKXetpDfAPxyhNXp4r8xV?usp=sharing)
Assignments:
* Code + report
* due on 15.02.2022
%% Cell type:code id: tags:
```
class Car:
def __init__( self, name, color, year):
self.name = name
self.color = color
self.year = year
def present( self ):
return 'Hey! I am '+self.name+', I am '+self.color+' and I appeared in '+str(self.year)
def be_painted( self, new_color ):
self.color = new_color
def love( self, other_car ):
return self.name+' is in love with '+other_car.name
```
%% Cell type:code id: tags:
```
flash = Car( 'Flash McQueen', 'red', 2006 )
flash.present()
```
%% Output
'Hey! I am Flash McQueen, I am red and I appeared in 2006'
%% Cell type:code id: tags:
```
flash.be_painted( 'purple' )
flash.present()
```
%% Output
'Hey! I am Flash McQueen, I am purple and I appeared in 2006'
%% Cell type:markdown id: tags:
## Exercise:
- define a new object of type Car with the following attributes: its name is Sally Carrera, its color is blue and it has the same year as the object my_car.
- call the method love of the Car class with Flash and Sally.
%% Cell type:code id: tags:
```
```
%% Output
'Hey! I am Sally Carrera, I am blue and I appeared in 2006'
%% Cell type:markdown id: tags:
## Inheritance
https://www.geeksforgeeks.org/python-oops-concepts/#:~:text=In%20Python%2C%20object%2Doriented%20Programming,%2C%20etc.%20in%20the%20programming.
%% Cell type:code id: tags:
```
# Parent class
class Person(object):
# __init__ is known as the constructor
def __init__(self, name, idnumber):
self.name = name
self.idnumber = idnumber
def display(self):
print(self.name)
print(self.idnumber)
def details(self):
print("My name is {}".format(self.name))
print("IdNumber: {}".format(self.idnumber))
```
%% Cell type:code id: tags:
```
# child class
class Employee(Person):
def __init__(self, name, idnumber, salary, post):
super().__init__(name, idnumber )
self.salary = salary
self.post = post
def details(self):
print("My name is {}".format(self.name))
print("IdNumber: {}".format(self.idnumber))
print("Post: {}".format(self.post))
```
%% Cell type:markdown id: tags:
## Exercise:
- Create an object of the class Employee
- Print his name and id number.
%% Cell type:code id: tags:
```
# creation of an object variable or an instance
emy = Employee('emily', 42, 90000, 'happy manager')
# calling a function
emy.display()
```
%% Output
emily
42
%% Cell type:code id: tags:
```
```
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
File deleted
File deleted
File deleted
File deleted
File deleted
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment