You can download this code by clicking the button below.
This code is now available for download.
This function creates a simple command-line application using the Typer library, allowing users to obtain random quotes through the command line.
Technology Stack : Typer
Code Type : Python Function
Code Difficulty : Intermediate
from typer import Typer, Argument
def random_quote():
quotes = [
"The only way to do great work is to love what you do. - Steve Jobs",
"The future belongs to those who believe in the beauty of their dreams. - Eleanor Roosevelt",
"Success is not final, failure is not fatal: It is the courage to continue that counts. - Winston Churchill",
"Believe you can and you're halfway there. - Theodore Roosevelt",
"The secret of getting ahead is getting started. - Mark Twain"
]
app = Typer()
@app.command()
def get_quote():
quote = quotes[randint(0, len(quotes) - 1)]
print(quote)
app.run()
if __name__ == "__main__":
random_quote()