14,948 Topics

Member Avatar for
Member Avatar for wine_1

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, my original understanding is that x will keep data's first two dimensions, and take a slice from data on the …

Member Avatar for slate
0
278
Member Avatar for paul_46

Hi there Im doing a project at the moment and need to find the numbers 1,2 and 3 i(all) in any order entered by the user. A=[] B=[0,1,2,3,4] lengthOfList = int(input("Enter the number of elements:")) for i in range(0,lengthOfList): elm = int(input("Enter and element value: ")) A.append(elm) print(A) Code so …

Member Avatar for rproffitt
0
288
Member Avatar for Amber_6

I'm stuck on this problem for a day. Since no one responds my question on stack overflow, I hope somebody here may help. I'm trying to build a dictionary of shakespeare's plays that records the act and scene of the first speech of each character, and the number of speeches …

Member Avatar for Gribouillis
0
342
Member Avatar for tjy92

I need to write a program that reads data from a text file, and prints it. These are the specifications. And then manipulate the program to determine this: -The number of uppercase letters in the file -The number of lowercase letters in the file -The number of digits in the …

Member Avatar for Reverend Jim
0
3K
Member Avatar for wine_1

Hi, I am using the following code segment to input image from file. The code itself works fine. However, I have a question regarding line 7 img=img/255 I understand that it aims to scale the img value to 0 and 1. But I am not sure whether I should add …

Member Avatar for Gribouillis
0
247
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
217
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
495
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
529
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
8K
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
890
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
980
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
258
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
598
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
377
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
300
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
648
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
173
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
325
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
107
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
804
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
351
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
502
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
175
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
361
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
185
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
453
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

The End.