0% found this document useful (0 votes)
17 views2 pages

Python Note Management System

The document defines a Note class to store and manage notes. The class has methods to add notes, get a random note, view all notes, and clear notes. An example shows using the Note class to add and retrieve notes.

Uploaded by

northzack986
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views2 pages

Python Note Management System

The document defines a Note class to store and manage notes. The class has methods to add notes, get a random note, view all notes, and clear notes. An example shows using the Note class to add and retrieve notes.

Uploaded by

northzack986
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Import random

Class Note:

Def __init__(self):

[Link] = []

Def add_note(self, note):

[Link](note)

Def get_random_note(self):

If not [Link]:

Return “No notes available.”

Return [Link]([Link])

Def view_notes(self):

If not [Link]:

Return “No notes available.”

Return “\n”.join([Link])

Def clear_notes(self):

[Link] = []

# Contoh penggunaan:

If __name__ == “__main__”:

My_notes = Note()

My_notes.add_note(“Belajar Python hari ini.”)

My_notes.add_note(“Beli bahan makanan besok.”)

My_notes.add_note(“Telepon dokter untuk periksa rutin.”)

Print(“Semua catatan:”)
Print(my_notes.view_notes())

Print(“\nCatatan acak:”)

Print(my_notes.get_random_note())

My_notes.clear_notes()

Print(“\nSetelah menghapus semua catatan:”)

Print(my_notes.view_notes())

You might also like