15,406 Topics

Member Avatar for
Member Avatar for sandman64

i'm trying to use the elif statement but every time i try to use it it gives a syntax error. here's the code: [code] n = input() while n != 2: n = n - 2 print "number is even" elif: n < 2: print "number is odd" [/code]

Member Avatar for Swathi_4
0
222
Member Avatar for Viasur

Hello to everyone! Yes, Im a newbie and I have a problem that is kind of a pain. I receive an error "Invalid Syntax", when trying to run this. The file mesaure.csv has been created and it is locate on the correct folder with the .py file. Whe I try …

Member Avatar for Gribouillis
0
4K
Member Avatar for Nether_1

Firstly, I would like to apologize for the massive number of nooby crap questions that come out of my account. I'm an emerging programmer that doesn't always know what he's doing, so I'm sorry. Secondly, the problem. I'm writing this code: class Object(): def __init_(self, vertices, color, name): self.color = …

Member Avatar for Gribouillis
0
538
Member Avatar for pasta

Hello, i recently learned Pig Latin and how it works (some stupid hard shakespeare language in Python lol) and in CodeAcademy it says "print Pig Latin" in pig latin which i do not know how and i need some help, here is the code i entered for the program on …

Member Avatar for Gribouillis
0
535
Member Avatar for Nether_1

Hey everybody. I'm currently working on making a simple 2D "engine" of sorts in which I can assign certain objects to certain coordinates and it will render them out there. It's mainly to be about 2D animation and the like, but that's besides the point. I'm working on a coordinate …

Member Avatar for Nether_1
0
9K
Member Avatar for mms6

def binding_locations(strA, strB): The first parameter represents a strand of DNA. The second parameter is one strand from a recognition sequence. Return a list of all the indices where the recognition sequence appears in the DNA strand. (These are the restriction sites.) For example, if the DNA palindrome appears at …

Member Avatar for Hassaan_4
-2
894
Member Avatar for Mengchen

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 = turtle.Point(x,y) triangle = turtle.Polygon(vertices) a = triangle.side() b = triangle.side() c = triangle.side() m1 = tirangle.median m2 = triangle.median …

Member Avatar for slate
0
988
Member Avatar for Lucas_10

It would be good for some people to help me out on putting sounds in my application without Pygame, because it doesn't work on my PC. If you can then it would be highly appreciated for your help. If you could not reply then you could do a download for …

Member Avatar for rproffitt
0
261
Member Avatar for Gowda_1

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.. Python 3.4.3 (v3.4.3:9b73f1c3e601, Feb 24 2015, 22:43:06) [MSC v.1600 32 bit (Intel)] on win32 Type "copyright", "credits" or "license()" for …

Member Avatar for Lucas_10
0
613
Member Avatar for Tim_10

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 stuck on how to average the sum of the cubes. Help Please. This is what I have so far. def …

Member Avatar for tinstaafl
0
381
Member Avatar for Amber_6

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 point w (int): width of each letter, in pixels spacing (int): separation between consecutive letters, in pixels """ speed(0) drawInitials …

Member Avatar for slate
0
303
Member Avatar for Andrew_34

I am trying to send a message to my websocket server but I keep getting this error. Traceback (most recent call last): File "send.py", line 5, in <module> ws = websocket.create_connection("ws://ipaddress:9001") AttributeError: 'module' object has no attribute 'create_connection' I created a python server file server is started but when I …

Member Avatar for Andrew_34
0
680
Member Avatar for yordanos_1

Using Python, create a program that simulates a bank machine and transactions on a bank machine. Requirements: · Your bank machine must have an intro message that welcomes you. · The account balance is given at the beginning of the transaction and it should start at $1000.00. · It must …

Member Avatar for rproffitt
0
175
Member Avatar for 華星

import requests import pandas as pd import csv from bs4 import BeautifulSoup from pandas import Series,DataFrame import unicodecsv def name1(): url="https://www.agoda.com/zh-tw/pages/agoda/default/DestinationSearchResult.aspx? asq=%2bZePx52sg5H8gZw3pGCybdmU7lFjoXS%2baxz%2bUoF4%2bbAw3oLIKgWQqUpZ91GacaGdIGlJ%2bfxiotUg7cHef4W8WIrREFyK%2bHWl%2ftRKlV7J5kUcPb7NK6DnLacMaVs1qlGagsx8liTdosF5by%2fmvF3ZvJvZqOWnEqFCm0staf3OvDRiEYy%2bVBJyLXucnzzqZp%2fcBP3%2bKCFNOTA%2br9ARInL665pxj%2fA%2bylTfAGs1qJCjm9nxgYafyEWBFMPjt2sg351B&city=18343&cid=1732641&tag=41460a09-3e65-d173-1233-629e2428d88e&gclid=Cj0KEQjwvve_BRDmg9Kt9ufO15EBEiQAKoc6qlyYthgdt9CgZ7a6g6yijP42n6DsCUSZXvtfEJdYqiAaAvdW8P8HAQ&tick=636119092231&isdym=true&searchterm=%E5%A2%BE%E4%B8%81&pagetypeid=1&origin=TW&cid=1732641&htmlLanguage=zh-tw&checkIn=2016-10-20&checkOut=2016-10-21&los=1&rooms=1&adults=2&children=0&isFromSearchBox=true&ckuid=1b070b17-86c2-4376-a4f5-d3b98fc9cf45" source_code=requests.get(url) plain_text=source_code.text soup=BeautifulSoup(plain_text,"lxml") for a in soup.find_all("h3",{"class":"hotel-name"}): b=a.string.strip() print(b) csvfile=open('hotel.csv','w') wr=unicodecsv.writer(csvfile,encoding='utf-8') for item in b: wr.writerow(b) csvfile.close name1() I use python3 and win10 to write this code. I …

Member Avatar for 華星
1
332
Member Avatar for Pandey_1

How can i set a frame according to parent window size? I was trying to set it but it is taking only region where button displayed from Tkinter import * class Example: def __init__(self, parent): self.parent = parent self.parent.title("CBLFinder") self.initUI() def initUI(self): self.frm1=Frame(self.parent,background="white",\ borderwidth=5,relief="sunken",\ width=400,\ height=500) #print self.parent.winfo_reqwidth(),self.parent.winfo_reqheight() btn=Button(self.frm1,text="Submit",command=self.update_frame) btn.grid(row=2,column=2,padx …

0
110
Member Avatar for PCSAWICK829

Alright. I'm teaching myself python from 'Learn Python the Hard Way: 3rd Edition' by Zed Shaw.. it's been informative so far. Definitely learning. After his lessons, he gives study drills, extra project to put your learning to use. He challenged us to: "Find out what Zork and Adventure were. Try …

Member Avatar for Conrad_2
0
9K
Member Avatar for giancan

Dear All, I have a very long list of values as follow (43, 560) (516, 1533) (1316, 3047) (520, 1528) (3563, 1316) (45, 557) (3562, 1312) (2686, 1964) (2424, 3340) (3559, 1317) (50, 561) (2427, 3336) (1313, 3046) (3562, 1313) (3559, 1318) (2689, 1962) (2429, 3339) (3721, 2585) (1317, 3048) …

Member Avatar for JamesCherrill
0
824
Member Avatar for hamzah_1

Is there a way I can fix the way ji get neighbors of a 2d coordinate? """6.009 Lab 5 -- Mines""" def dump(game): """Print a human-readable representation of game. Arguments: game (dict): Game state >>> dump({'dimensions': [1, 2], 'mask': [[False, False]], 'board': [['.', 1]]}) dimensions: [1, 2] board: ['.', 1] …

Member Avatar for rproffitt
0
367
Member Avatar for Pandey_1

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 to new dictionary '''inputstatus = { 'maggi': 1, \ 'pizza': 1, \ 'cold drinks': 1, \ 'fries': 1, \ 'chapati': …

Member Avatar for Gribouillis
0
513
Member Avatar for Pandey_1

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 will be unticked

Member Avatar for slate
0
179
Member Avatar for Pandey_1

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 selected checkbox which are generated based on list but while i am doing such things it generate checkbox many time …

Member Avatar for Pandey_1
0
365
Member Avatar for Amin_3

Write a program that prints a table of Celsius temperatures from 0 to 20 degrees and prints the corresponding temperature in Fahrenheit. This program MUST use a loop. The first digit in each temperature must line up with the first digit of the temperatures above it so the output forms …

Member Avatar for rproffitt
0
187
Member Avatar for Pandey_1

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 h = 450 sw = self.parent.winfo_screenwidth() sh = self.parent.winfo_screenheight() x = (sw - w)/2 y = (sh - h)/2 self.parent.geometry('%dx%d+%d+%d' …

Member Avatar for Pandey_1
0
7K
Member Avatar for Artur_5

Hello, I'm totally new to programming and wanted to make a text-based game based on what I know, but I've met a problem I don't know how to fix. Also this code is not finished, I'm just trying to get it to work first. Basically, I want the loop to …

Member Avatar for Gribouillis
0
484
Member Avatar for AutoPython

Okay, I'm trying to make a python game (not with pygame), I want it to use the arrow keys. But the thing is, I don't know how to get it to respond to the arrow keys. So here's what I want to do. If the user presses the up arrow …

Member Avatar for Gribouillis
1
49K
Member Avatar for <HHH>

Hello, I'm trying to use md5 in python3 using the attached code from hashlib import md5 password = 'pa$$w0rd' h = hashlib.md5() print(h.hexdigest()) put it gives me this error (cannot import name 'md5') and when i try to import hashlib only it gives this error (module 'hashlib' has no attribute …

Member Avatar for <HHH>
0
2K
Member Avatar for bob_15

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 shuffle import time #------------------------------------------------------------------------------------------------------- def database1(): conn = sqlite3.connect("Database1.db") #connection to database #directory will need to be changed in order …

Member Avatar for slate
0
721
Member Avatar for Harambe

hello im harambe and need help with some course work for my GCSE's i like memes and message me if you can help as im 16 and my fianl exam is next week and i dont know aht an array is help!!!!!!!!!!!

Member Avatar for happygeek
0
148
Member Avatar for Crazyscript77

Hi all, Ive been looking to convert one of my programs to include a GUI, and am having issues with the timing aspects of it. Ive included a mock scenario of what my problem is below: Ive defined my GUI as an object via a class, and am using the …

Member Avatar for Gribouillis
0
7K
Member Avatar for hpoddar

How to read properties file in Python? I found ConfigParser() but it has a 'section' limitation, so looking for other alternatives. Thanks, Harsh

Member Avatar for Anand_10
0
12K
Member Avatar for zero_1

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

Member Avatar for slate
0
159
Member Avatar for Sandeep_21
Member Avatar for pythonBasic
Member Avatar for mcroni

have a code that loads an image online with the AsyncImage module in kivy. i wrote the code in python3 which runs well on the pc but doesnt work on a packaged apk. i think this is because i packaged it using python2.7 buildozer. thanks an image showing the error …

Member Avatar for mcroni
0
703
Member Avatar for Blair_2

Hi, I am trying to create something which you can type into entry boxes, then save that information to a .txt file. I have got this to work however I wish to name the file as what is stored in one of the entry boxes and cannot figure out how …

0
145
Member Avatar for tayeb d

int* poly = new int[lines.size()]; for(int i=0;i<lines.size();i++)poly[i] = - 1; int curPoly = 0; vector<vector<cv::Point2f> > corners; for (int i = 0; i < lines.size(); i++) { for (int j = i+1; j < lines.size(); j++) { cv::Point2f pt = computeIntersect(lines[i], lines[j]); if (pt.x >= 0 && pt.y >= 0&&pt.x<img2.size().width&&pt.y<img2.size().height){ …

Member Avatar for rproffitt
0
995
Member Avatar for Nether_1

I'm writing a code that requires me to import multiple python files that are similiar to that of a .obj file, in the sense that they will create a 3D figure using vertices and lines, etc. The problem is, the files will have the same name for a list (called …

Member Avatar for rproffitt
0
223
Member Avatar for Crazyscript77

Hi all, I have been trying to use python to automate a sequence of processes on my computer, one of which is starting a hosted network. I have used subprocess to interact with command prompt (windows 10), and am struggling to pass sequential commands. I am trying to first send …

Member Avatar for Gribouillis
0
11K
Member Avatar for <HHH>

Hello, Im trying to install pymongo package to be able to connect to MongoDB using pip pip install pymongo but it produce the below error Could not find a version that satisfies the requirement pymongo (from versions: ) No matching distribution found for pymongo

Member Avatar for ~s.o.s~
0
2K
Member Avatar for <HHH>

Hello, i have a sample web appliaction which get a value from HTML text feild and redirect to HTML page according to the value passed but the problem is that i can't get the value entered in the html text throught (request.form) method I get the below error werkzeug.routing.BuildError: Could …

Member Avatar for snippsat
0
597
Member Avatar for karthik_6

hi all, how to parse an xml attributes using python. I want to read or extract msg values from xml using python. <msg timestamp="20160817 12:46:42.520" level="INFO">Average : 0.14 % CPU (%) 10 Aug 07:00 2 12 Aug 07:00 maximum 5.17 average 0.13</msg>

Member Avatar for snippsat
0
633
Member Avatar for <HHH>

Hello I have created two classes one for the user and the other for address every thing is ok and the tables of the two classes created in my database but when i try to initiate a new object from user class i get the below error "sqlalchemy.exc.InvalidRequestError: Mapper 'Mapper|user|user' …

Member Avatar for <HHH>
0
10K
Member Avatar for Azim_1

Hye I'm new to c++ language. Can anyone suggest me what is the best programming software should I learn ? And how I'm gonna learn coding ?

Member Avatar for rubberman
0
294
Member Avatar for rhys1619

Hi, im trying to add a slapsh screen before my game. It will display a png and the use can either press "e" to continue or "q" to quit. when i run this in my game is says that pygame.display.update() is the problem. Please help thanks. def game_intro(): intro = …

Member Avatar for rhys1619
0
1K
Member Avatar for Maikel

Hi guys, I'm new to Python have get done a lot by searching. Now I try to bind a scroll wheel to canvas, but it doesn't do anything. Will someone look at the code what I do wrong? I tried to keep my snippet clean. Hope It's enough. class Viewer(tk.Toplevel): …

Member Avatar for rproffitt
0
789
Member Avatar for vegaseat
Member Avatar for Zach_2

Whenever I go to transfer a file from my server to my client, I get a new file, but the data does not go through. It prints server side once it is open, but it won't transfer the data to my new file. Here is the code:https://gist.github.com/anonymous/8f70b3e2eca8606dee2c245ce64e9b63 All I want …

Member Avatar for Gribouillis
0
288
Member Avatar for rhys1619

hi, so ive been trying to add a splash screen to the start of my game. the user presses "e" to continue and "q" to quit. it's not working, could anyone help. import os import pygame import random pygame.init() #Colours im using in the game white = (255,255,255) black = …

0
265
Member Avatar for lewashby

I've tinkered with php in the past but I'v also enjoyed playing around with python. I have been wanting to give python a try as a possible alternative to php but I haven't had much luck. All of the videos I find on the subject are about setting up Django …

Member Avatar for lewashby
0
1K
Member Avatar for <HHH>

Hello, I'm trying to write my first cookie on python but when i import cookie or even http.cookie it gives me the below error import cookie c = cookie.SimpleCookie() c["value"] = "first" print (c) ImportError: No module named 'cookie' [Finished in 0.3s with exit code 1] [shell_cmd: python -u "C:\Users\hohait\Desktop\test.py"] …

Member Avatar for <HHH>
0
5K

The End.