DEV Community

Cover image for Python generated jokes πŸ˜‚πŸ€£
Ajith R
Ajith R

Posted on

Python generated jokes πŸ˜‚πŸ€£

The Alexa APIs for Python consists of python classes that represent the request and response JSON of Alexa services.

The ASK Software Development Kits (SDKs) include development tools and libraries that give you access to Alexa features. These SDKs are available in Node. js, Java, and Python. Alternatively, you can develop your skill in any language and accept requests from and send responses to the Alexa service.

Pyjokes Library

Pyjokes is a python library for one line jokes for programmers (jokes as a service). You can get funny one-liner, mostly related to programming.

Install and Importing Library

_#install on command line _

pip install pyjokes
Enter fullscreen mode Exit fullscreen mode

import in python idle/editor

import pyjokes

1)

get_joke()
Enter fullscreen mode Exit fullscreen mode

It only returns one joke at a time. It is generated randomly.
Parameters - It has two parameters language and category.
Return Type - It returns string type (str).

joke1 = pyjokes.get_joke (language='en', category= 'all') print (joke1)
#output: any random joke
Enter fullscreen mode Exit fullscreen mode

2)

get_jokes()
Enter fullscreen mode Exit fullscreen mode

It returns a list of jokes.
Parameter- The parameters are the same as above- language and category.
Return type- *It returns a list.

jokes= pyjokes.get_jokes (language='en', category=
'neutral')
for i in range(5):
print (i+1, ".", jokes[i])
#output: list of jokes
Enter fullscreen mode Exit fullscreen mode

Parameter: Category

β€ŒFor geeky jokes -'neutral' (It is chosen by default)
β€’ For Chris Norris Jokes - 'chuck'.
β€’ If you want all type of jokes - 'all'

Top comments (0)