#🔒 Need help to correct my python script

66 messages · Page 1 of 1 (latest)

sterile pollen
#

Does someone can help me in vocal to make work my script pls ? It's not a difficult one.

flint leafBOT
#

@sterile pollen

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

sterile pollen
stable axle
sterile pollen
#

how

granite stump
stable axle
#

Use three of these ` at the beginning and end

sterile pollen
#

from abc import ABC, abstractmethod
class Personne(ABC):

def __init__(self, nom, prenom, adresse):
    self.nom = nom
    self.prenom = prenom
    self.adresse = adresse

@abstractmethod
def question(self):
    self.nom = input("Veuillez encoder le NOM de la personne 😊
    self.prenom = input("Veuillez encoder le PRÉNOM de la personne 😊
    self.adresse = input("Veuillez encoder l'ADRESSE de la personne 😊
    return self.nom, self.prenom, self.adresse

class Employe(Personne):
def init(self, nom, prenom, adresse, fonction):
self.fonction = fonction
super().init(nom)
super().init(prenom)
super().init(adresse)

def questionEmploye(self):
    self.fonction = input("Veuillez encoder la FONCTION de l'employé' 😊
    return self.fonction

class Eleve(Personne):
def init(self, matricule):
self.matricule = matricule
def questionEleve(self):
self.matricule = input("Veuillez encoder le matricule de l'élève' 😊
return self.matricule

#Main execution

entree = input("Si vous désirez encoder un EMPLOYÉ tapez: 1 \nSivous désirez encoder un ÉLÈVE tapez: 2 \nSi vous désirez quitter le programme tapez: 0 \n")

if int(entree) == 1:
monEmploye = Employe

if int(entree) == 2:
monEleve = Eleve

if entree == 0:
quit

granite stump
#
super().__init__(nom, prenom, adresse)
#

and your eleve class is missing init call to superclass

granite stump
#

You should also call
super().__init__(nom, prenom, adresse)
in your eleve class's __init__

sterile pollen
#

done

granite stump
#

Note that abstract method should not have an implementation.

#

so your Person's question method should either have no implementation, or not be marked with the abstractmethod decorator

sterile pollen
#

In this exercise I must make use of abstract method

granite stump
#

Your code needs some restructuration then

sterile pollen
#

how

#

finally I must

granite stump
#
from abc import ABC, abstractmethod


class Person(ABC):
    def __init__(self):
        self.name = input("Enter your name: ")
        self.last_name = input("Enter your last name: ")
        self.address = input("Enter your address: ")

    @abstractmethod
    def question(self):
        pass


class Employee(Person):
    def __init__(self):
        super().__init__()
        self.function = None

    def question(self):
        self.function = input("Enter your function: ")

Here's a structure that may fit your needs

#

I'm sorry I have to go

#

hope it helps

sterile pollen
#

If you group common data into a class, the class must be abstract. You can force the error linked to the abstraction of the class by annotating for example the str() method using the appropriate annotation.

#

here is the consign

sterile pollen
#

from abc import ABC, abstractmethod

class Person(ABC):
def init(self):
self.nom = input("Veuillez encoder le NOM de la personne ")
self.prenom = input("Veuillez encoder le PRÉNOM de la personne ")
self.adresse = input("Veuillez encoder l' ADRESSE de la personne ")

@abstractmethod
def question(self):
    pass

class Employe(Person):
def init(self):
super().init()
self.fonction = None

def question(self):
    self.fonction = input("Veuillez encoder la FONCTION de la personne ")

class Eleve(Person):
def init(self):
super().init()
self.matricule = None

def question(self):
    self.matricule = input("Veuillez encoder le MATRICULE de la personne ")

#Main execution

entree = input("Si vous désirez encoder un EMPLOYÉ tapez: 1 \nSivous désirez encoder un ÉLÈVE tapez: 2 \nSi vous désirez quitter le programme tapez: 0 \n")

if int(entree) == 1:
monEmploye = Employe

if int(entree) == 2:
monEleve = Eleve

if entree == 0:
quit

#

here is the script after modifications

flint leafBOT
#
Formatting code on Discord

Here's how to format Python code on Discord:

```py
print('Hello world!')
```

These are backticks, not quotes. Check this out if you can't find the backtick key.

For long code samples, you can use our pastebin.

granite stump
#

does it work as you expect?

sterile pollen
#

it didn't :'c

#

Here is the consign of my test
CONTEXT
You work within a training establishment and, in order to facilitate the management of people attending the establishment, you are asked to create a small on-the-go application allowing the coding of both members of the establishment's staff and coding of students attending it.
An employee is characterized by: his last name, his first name, his address and the position he occupies within the establishment.

A student, for his part, is characterized by his name, his first name, his address, his student number generally made up of the first 2 letters of his first name, the first 2 letters of his last name and of 4 digits and the list of courses he attends within the establishment.

The interface, although minimalist, should be easy to use. It must ask the user if they want to encode an employee (1) or a student (2) or exit the program (0).
Once the choice is made. This must request the encoding of all the characteristics specific to the person to be encoded: surname, first name, address, function / surname, first name, address, registration number.

In the case of encoding a student, once all the personal data has been filled in, the program will ask you if you want to add courses to this student.

Finally, when the user decides to leave the program, it will display all the information of the different people encoded during the encoding session.

#

(used google traduction)

broken cradle
#

!code

flint leafBOT
#
Formatting code on Discord

Here's how to format Python code on Discord:

```py
print('Hello world!')
```

These are backticks, not quotes. Check this out if you can't find the backtick key.

For long code samples, you can use our pastebin.

broken cradle
smoky bane
#

please on god do not write your code in another language

#

theres a reason why all languages are english

broken cradle
sterile pollen
smoky bane
broken cradle
#

We have many visitors here who are not working in English, nor should they need to. They make a huge effort to communicate with us here in English, a second language for them.

smoky bane
#

same

smoky bane
broken cradle
granite stump
broken cradle
smoky bane
smoky bane
#

haven

granite stump
#

it doesnt meet all your teachers requirements, still requires you to write a little bit of code

smoky bane
#

non english code smh

sterile pollen
#

heaven*

smoky bane
#

does it exist though

granite stump
#

!paste

flint leafBOT
#
Pasting large amounts of code

If your code is too long to fit in a codeblock in Discord, you can paste your code here:
https://paste.pythondiscord.com/

After pasting your code, save it by clicking the Paste! button in the bottom left, or by pressing CTRL + S. After doing that, you will be navigated to the new paste's page. Copy the URL and post it here so others can see it.

granite stump
#

I'd recommend you take a look at the comments I've put and also work on the TODOs

sterile pollen
#

I am checking, huge thanks already man

granite stump
#

You're welcome. Happy to help!

flint leafBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.