Software Development
Member Avatar

I have a rock paper scissors code that works in python 2.7- it gives you 4 options (rock, paper scissors, or quit). However, I have to add a while loop …

Topic by Mark_64

I know, you did not ask, but the program should be more tight (compact).

Something like this:

import random
def main() :
    tie_message="It's a draw. You both threw %s."
    win_message="You …
Software Development
Member Avatar

I am learning python from "Learn Python The Hard Way", I came across a source code

"from sys import argv" and got an explanation that sys is a module from …

Topic by ayushi_3

Beside Gribouillis' explanation.

Although, sounds simple but still not able to understand the concept behind.

Core concepts are the most hard things.

I would like to know how …

Computer Science
Member Avatar

Help me create a code that will ask the user the guess the randomly generated integer by the computer using recursive function. Thanks!

Topic by Jeah_1

Good luck!

from random import randint
def guess():
    if int(input("Guess the number (1-10):"))==randint(1,10):
        print("Got it") 
     else:
        print("Wrong!")
        guess()
guess()
Software Development
Member Avatar

I have made two windows
startscreen=tk()
and FirstScreen=tk()
I want to make a button on startscreen that opens up the window *FirstScreen
This is the code for the startscreen

startscreen=Tk() …
Topic by Saif_6

You did not mention any reason that justifies creating a new tkinter mainloop. So take a look at these:
http://tkinter.unpythonic.net/wiki/ModalWindow
http://effbot.org/tkinterbook/tkinter-dialog-windows.htm

You can make FirstScreen a modal toplevel window.

If …

Programming
Member Avatar

There is a multi-dimensional array, e.g., data is of shape (1,320,320,1)

I once saw a function which uses

x=data[:,c:-c,d:-d]

I am not very clear about what does this mean, …

Topic by wine_1

I am not very clear about what does this mean, my original understanding is that x will keep data's first two dimensions, and take a slice from data on …

Game Development
Member Avatar

How could I improve my code for Bubble Blaster.

from Tkinter import *
HEIGHT = 626
WIDTH = 1238
window = Tk()   
window.title('Bubble Blaster 1.8 - By Lucas - AiroTM …
Topic by Lucas_10

Well. I would gladly demonstrate, what I am talking about.
Please, show me a working code!
If you have difficulties posting here, use pastebin.com.

Software Development
Member Avatar

I need to comput and display the sum and average of the cubes of the even natural numbers between 2 and n. Where n is entered by the user. Im …

Topic by Tim_10

Here's the code from the pastebin:

print ("This calculates the sum of the cubes of the 1st natural numbers")
natn = eval(input("How many cube numbers do you want to sum? …
Game Development
Member Avatar

How could I improve my code for Bubble Blaster.

from Tkinter import *
HEIGHT = 626
WIDTH = 1238
window = Tk()   
window.title('Bubble Blaster 1.8 - By Lucas - AiroTM …
Topic by Lucas_10

First try to make a version of it, that actually can be run by others.
If I copy-paste your code into notepad, then save it, it does not run.

I …

Software Development
Member Avatar
from turtle import *
import random

def allTriMedian (w=300):
    speed (0)
    vertices = []
    point = turtle.Point(x,y)

    for i in range (3):
        x = random.randint(0,300)
        y = random.randint(0,300)
        vertices.append(trutle.Point(x,y))
        point …
Topic by Mengchen

I/ if you import everything from turtle, like this:
from turtle import *

Then you cannot make statements like this:
point = turtle.Point(x,y)

You should do: import turtle

II/ allTriMedian …

Software Development
Member Avatar

I need to comput and display the sum and average of the cubes of the even natural numbers between 2 and n. Where n is entered by the user. Im …

Topic by Tim_10
  • You are not adding up the even cubes. You are adding up all cubes of numbers between 0 and natn-1.Look up range documentation, how to generate even numbers.
  • ...
Programming
Member Avatar

I'm new to python, for my project I need to send mail from python.. I'm getting the following error can someone please help me how to get out of it.. …

Topic by Gowda_1

Google is your friend.

https://www.google.hu/search?q=python+smtplib+tutorial+gmail

First hit:
http://naelshiab.com/tutorial-send-email-python/

Which sais:
[ EDIT: Gmail made some security change change recently. You now have to allow “less secure apps” on your account. …

Software Development
Member Avatar

I want to convert letters "M", "E" and "D" into maritime flags

 from turtle import *

def drawInitials (ref=(0,0), w=100, spacing=10):
"""Params:
    ref (int 2-tuple): bottom right corner, the reference …
Topic by Amber_6

I do not understand.

  • Do you want to draw the maritime flag images using turtle graphics or you want to put the downloaded flag images on a canvas?
  • ...
Software Development
Member Avatar

I have generated checkbutton from inputstatus dictionary to set as default values.After tht once it get display on GUI when i select it respected text and status will be added …

Topic by Pandey_1

There is a good example at the bottom of this page http://www.python-course.eu/tkinter_checkboxes.php . Take the time to read about the use of tkinter Variable classes.

Software Development
Member Avatar

Suppose i have one dictionary menu={'pizza':1,'Burger':1,'sandwitch':0}
when i run tkinter gui these all key will be displayed on GUI. If value is 1 then respected key must be ticked rest …

Topic by Pandey_1

python3:

import tkinter as tk
master = tk.Tk()
menu={'pizza':1,'Burger':1,'sandwitch':0}
menuvars={}
for row, (key, value) in enumerate(menu.items()):
    menuvars[key]=tk.IntVar()
    menuvars[key].set(value)
    tk.Checkbutton(master, text=key, variable=menuvars[key]).grid(row=row, sticky=tk.W)
tk.mainloop()
Software Development
Member Avatar

There is one application where two radio buttons are available.i.e default and custom. If custom is selected then one panel will be visible which contain available drives list of not …

Topic by Pandey_1

How to make panel in tkinter or which widget will be used to hide and show checkbox?

I am not sure, I understand this sentence.

Something about the keywords …

Software Development
Member Avatar
from Tkinter import *
from ttk import Style

class Example(Frame):

    def __init__(self, parent):
        Frame.__init__(self, parent, background="#333")          
        self.parent = parent        
        self.parent.title("sample")
        self.parent.iconbitmap('sample.ico')
        self.pack(fill=BOTH, expand=1)
        self.centerWindow()
        self.initUI()

    def centerWindow(self):      
        w = 500 …
Topic by Pandey_1

Maybe I was not clear enough.

If you give a variable to a control object in tkinter, then the control reads its state from this variable. If you do not …

Software Development
Member Avatar
from Tkinter import *
from ttk import Style

class Example(Frame):

    def __init__(self, parent):
        Frame.__init__(self, parent, background="#333")          
        self.parent = parent        
        self.parent.title("sample")
        self.parent.iconbitmap('sample.ico')
        self.pack(fill=BOTH, expand=1)
        self.centerWindow()
        self.initUI()

    def centerWindow(self):      
        w = 500 …
Topic by Pandey_1

Line 46:
v = IntVar()

v goes out of scope.

If you bind v to something persistent (self), then it works.

How did you plan to read that variable …

Programming
Member Avatar

My current program is text based, is there a way to convert it to a GUI based one?

import sqlite3
from tkinter import*
import sys
import random
from random import …
Topic by bob_15

Yes. There is a way to convert it to a GUI based program.

Before you do that, I would recommend:

  • Make a self containained version, so others can run …
Programming
Member Avatar

How to update jquery on windows 7?
my jquery stil 1.4.3
i want to change it become version 1.7.3

thanks before

Topic by zero_1

Why is there a python tag?

Software Development
Member Avatar

I am new to python, in the below code i am reading 2 files and writing in 2 files. I want to open these files in seperate functions as to …

Topic by engrjd91

Hello there!

Short version: I do not understand the question.

Long version:
My eagle eye detected you posting the second question about the same project.

This should be a very …

Programming
Member Avatar

Okay so my code works, but I need a few more requirements for it and I can't seem to get them right even though they should be pretty simple. I …

Topic by grand_78

Please post a working code, to help others. Try to copy-paste your own posted code into a .py file and see, that it does not work. There is a syntax …

Programming
Member Avatar

question: write in python to take five input values and output:
a)the highest value
b)the lowest value
c)the average

(i need help with my homework)

Topic by firdevs

Besides from whathaveyoutried.com , I can only say:

values=[int(input("Give the number(%s): " % i)) for i in range(1,6)]
print("Highest: {} \n Lowest: {} \n Average: {}".format(max(values),min(values), sum(values)/len(values)))

But beleve me. …

Software Development
Member Avatar

I'm developing a dirt-simple text editor for personal use, customized the way I like it. My biggest difficulty is with grasping how OOP works. Could you kindly review the following …

Topic by Mickey_2

You use global imported variables locally.

There is no need to pass ScrolledText and Tk to the Scratchpad class's dunder init. This is redundant.

This is the same, but cleaned …

Software Development
Member Avatar

What software do you recommend for drawing layouts to be implemented in a ttk application? I'm looking for something simple and clutter-free where there aren't 10 zillion options I don't …

Topic by Mickey_2

I think the most used layout for tkinter is grid.

So grid paper and pen.

I know, this is not software. Others recommend that, too.

Software Development
Member Avatar

Help please, im using python 3 and im trying to print the state with maximum and minimum population from a text file...This is what the text file contains.

Alabama
AL …
Topic by j.parkerrrr

Here you are. I hope, this makes you a really good programmer.

f=open("states.txt").readlines()
states=sorted([(f[i].strip(),f[i+1].strip(),int(f[i+2])) for i in range(0,len(f)-3,3)],key=lambda x:x[2])
print("minimum population:",states[0])
print("maximum population:",states[-1])
Programming
Member Avatar

How to combine two class? so the output can be equal...
here's my code..

class year:
    def __add__(self, year):
        return (year)   
class day: 
    def __add__(self, day):
        return (day)
class month: …
Topic by zero_1
class Date(object):

    def __init__(self, year, month, day):
        self.year=year
        self.month=month
        self.day=day

    def __add__(self, other):
        if not isinstance(other,Delta):
            raise Exception("can only add Delta object")
        #FIXME handle the calendar 
        year=self.year+other.year
        month=self.month+other.month
        return Date(year,month,self.day) …
Software Development
Member Avatar

Just trying to find out which of these five isprime functions is the fastest.

Topic by vegaseat

There is my python implementation in this thread as an answer. Nobody bothered to read it …

Software Development
Member Avatar

Just trying to find out which of these five isprime functions is the fastest.

Topic by vegaseat

I hope nobody thinks these algos are used in the real world. There are much better algos to determine if a number is prime. Since the beginning of the 20th …

Software Development
Member Avatar

You are given N integers that are arranged circularly. There are N ways to pick consecutive subsequences of length M (M < N). For any such subsequence we can find …

Topic by Subin raj

There is no question.
So I have solved it.

Software Development
Member Avatar

Write a program that asks the user to enter a series of 20 numbers. Store the numbers in a list and display the lowest, highest, total, and average of the …

Topic by rebekah.stacy1

Python3

nums=[(int(input("Give me the number numero {}: ".format(i+1)))) for i in range(20)]
print("Lowest: {}\nHighest: {}\nTotal: {}\nAverage: {}".format(min(nums),max(nums),sum(nums),sum(nums)/len(nums)))

I hope that makes you smarter.