Beginner python practice
Well just getting into the flow of thing with Python. Reading a few books, finding it fairly easy as I already have some experience with C++/Java from school and Python is definetly my favorite thus far.
Anyway, I am getting a whole bunch of information on python, but haven't been putting it to much use. Thus, what I was wondering was if there are any sort of practice problems online that I can use? If anyone could point me in any sort of direction, I'd greatly appreciate it.
- Make a Text-To-Speech App (type and it says it)
- Modify the Speech-To-Text example that is in the documentation to make a "voice note" app (speak and it just writes out the words)
- Use the requests library to show a random joke from api.chucknorris.io (uses JSON)
Post your code here and ask folks to review it for you :)
Those are all great ideas @reticulated!
Oh and for anyone stumbling upon this..
Anyone who knows C, please contribute using ctypes, as well those who know Objective C, some objc_util examples.
Let's try to use our individual strengths to help others!
My favorite problem is always to design a game (though, to be fair, game design is the main reason I fell in love with programming in the first place). The app does have a nice Python game tutorial, try following that along and see if you can improve or change the game!
Another challenge: grab text from a website, parse it so you get only relevant information, and output that information in Pythonista. An easy example is take a look at a the Google "I'm feeling lucky" page and see what the result is.
And if you get that challenge down, you can take it a step further. Have the script visit a site with stocks or price ranges, and try to graph those prices in Python! This could be awesome if you're trying to built your own investment tools and want to apply your own algorithms to the graph. There's some good plot examples in the app to get you started on this.
Just some ideas! Have fun and ask yourself "what would I want my device to do, for me?" If it's not impossible then you can probably program it.
Here is my Chuck Norris api code:
"""downloads a random Chuck Norris joke or fact using the api"""
data = get_joke()
text = parse_json(data)
print('-' * 40)
print('| Chuck Norris Jokes |')
print('-' * 40)
response = requests.get('https://api.chucknorris.io/jokes/random')
if response.status_code == 200:
# rest = response.content
print("error unable to connect to api\n")
rest = response.content return rest
text = json.loads(data)
text = (text['value'])
formatted = str(text).strip()
chuck = button_tapped(sender)
sender.title = chuck
view = ui.load_view('chuck')
return # #view.present('full_screen')
if name == 'main':