Calculator using variable names

I’ve recently been assigned an assignment to create a word calculator, and given my knowledge in python is still quite lacking, I want to ask if anybody has any better ideas for any possible solutions. The question is here: Jimmy has invented a new kind of calculator that works with words rather than numbers. Input … Read more

Reversing a number

I was working through a programming challenge I found on Reddit and it seemed easy enough: Find all numbers less than \$10^n\$ where the number and its reverse (the reverse of \$123\$ is \$321\$) are both divisible by \$7\$ and then sum them all together. def challenge_229(power): numbers = [] for x in range(0, 10**power, … Read more

Removing entries from a dictionary containing bad words

I have a dictionary with each item containing a quote in another dictionary: { ‘example1’: {‘quote’: ‘And it must follow, as the night the day, thou canst not then be false to any man.\n’}, ‘example2’: {‘quote’: ‘What a piece of work is man! how noble in reason!.\n’} } I need to completely remove each entry … Read more

Python send UDP packet

I am trying to write a program to send UDP packets, as in The code appears to be in Python 2: import socket UDP_IP = “” UDP_PORT = 5005 MESSAGE = “Hello, World!” print “UDP target IP:”, UDP_IP print “UDP target port:”, UDP_PORT print “message:”, MESSAGE sock = socket.socket(socket.AF_INET, # Internet socket.SOCK_DGRAM) # UDP … Read more

Is there something similar to ‘rake routes’ in django? [duplicate]

This question already has answers here: Determine complete Django url configuration (10 answers) Closed 6 years ago. In rails, on can show the active routes with rake ( $ rake routes users GET /users {:controller=>”users”, :action=>”index”} formatted_users GET /users.:format {:controller=>”users”, :action=>”index”} POST /users {:controller=>”users”, :action=>”create”} POST /users.:format {:controller=>”users”, :action=>”create”} Is there a similar tool/command for … Read more

Form sending error, Flask

There is form with two <input type=”submit”>. But when i’m sending it, second submit causes error. layout: <form action=”{{ url_for(‘index’) }}” method=”post”> <input type=”submit” name=”add” value=”Like”> <input type=”submit” name=”remove” value=”Dislike”> </form> … if request.method == ‘POST’: if request.form[‘add’]: return redirect(url_for(‘index’)) elif request.form[‘remove’]: return redirect(url_for(‘index’)) … First submit(add) works well, but second(remove)…: Bad Request The … Read more