15,406 Topics

Member Avatar for
Member Avatar for Eric_8

I have a folder with 40 files in it which I want to loop through. When I print out the name of the file my code works fine: import os source = 'pathtofile' for root, dirs, filenames in os.walk(source): for file in filenames: print file It will print : File1 …

Member Avatar for Eric_8
0
14K
Member Avatar for Eric_8

Hi, I am fairly new to Python. I am familiar with the concept to pass data accross functions. In theory, def c(): r = raw_input("Ask Something? ") .. return r def p(x): ... do something r = c() p(r) The code below works just fine via Terminal ( python filename.py …

Member Avatar for Eric_8
0
331
Member Avatar for manyatha

input1: create external table db.emp(id int,name string) row formatted fields terminated by ',' location 'hadfs:.../'; create external table db.emp1(id int,name string) row formatted fields terminated by ',' location 'hadfs:.../'; input2: create table db.emp(id int,name string) location 'hadfs:.../';; create table db.emp1(id int,name string) location 'hadfs:.../'; requeried output: create external table db.emp(id …

Member Avatar for rproffitt
-1
369
Member Avatar for Hubert_2

Hello Need help. I try to insert a background sound in my program but I get ImportError message Below line 8 and 9 of my program import random, time, pygame, sys from pygame.locals import * Below the error message when running my program #C:\Users\user pc\AppData\Local\Programs\Python\Python35-32\python "C:\Users\user pc\SkyDrive\ISN\son essaie.py" #Process started …

Member Avatar for DeanMSands3
0
176
Member Avatar for Jesse_11

I need to make a timer for pygame to sit in the top left of the screen, but have no idea how. I want it to count down from 30secs to 0. please help cause I have no idea.

Member Avatar for DeanMSands3
0
513
Member Avatar for Nether_1

I'm attempting to write a code in which the user can add as many of a certain object as needed, and blit it on to a pygame window. Essentially a game engine of sorts. I need to make it so that they can add as many of these objects as …

Member Avatar for Gribouillis
0
567
Member Avatar for kiyo_1

i put this code:: matirial = raw_input ('what is your favorite lesson') if matirial == 'maths' or 'math' or 'Maths' or 'Math' or 'رياضيات': print 'like me broo!!' elif matirial == 'french' or 'francais' or 'French' or 'Francais' or 'الفرنسية': print 'sorry dude I love English more then french' elif …

Member Avatar for samson.dadson.3_1
0
232
Member Avatar for vegaseat

This code creates a sound file in Sun's simple AU audio format of a sine wave of given frequency, duration and volume.

Member Avatar for samson.dadson.3_1
1
2K
Member Avatar for Lynet
Member Avatar for omprakash_1

# Split a dataset based on an attribute and an attribute value def t_split(x, y, z): l, r = list(), list() for row in z: if row[x] < y: l.append(row) else: r.append(row) return l, r # Calculate the Gini index for a split dataset def gini_index(grp, class_values): gini = 0.0 …

Member Avatar for rproffitt
0
327
Member Avatar for Mae_3

I tried making a code that displays images in a tkinter window along with a text underneath however its positioned in the top but I want it in the center. The path "C:\Users\ariel\Desktop\arrayofimages.txt" has: > C:\\Users\\ariel\\Pictures\\photoimage1\\1.jpg > C:\\Users\\ariel\\Pictures\\photoimage1\\2.jpg > C:\\Users\\ariel\\Pictures\\photoimage1\\3.jpg > C:\\Users\\ariel\\Pictures\\photoimage1\\4.jpg > C:\\Users\\ariel\\Pictures\\photoimage1\\5.jpg > C:\\Users\\ariel\\Pictures\\photoimage1\\6.jpg > C:\\Users\\ariel\\Pictures\\photoimage1\\7.jpg The path …

Member Avatar for rproffitt
0
3K
Member Avatar for Ace_4

# print ('Let me help you order a pizza. What size would you like?' ' a. small ($7.99) b. medium ($14.99) c. large ($18.99)') choice = input('Please enter a or b or c: ') prices = {'a':7.99 , 'b':14.99 , 'c':18.99} if choice == 'asdf' : print("Ok fam, you became …

Member Avatar for rproffitt
0
194
Member Avatar for Mirty

I need help with some questions.They were 20 of them but this 5 have been so hard for me. Any help I get will be highly appreciated. Cheers!!! 1.When mergesort is implemented on a linked list it is possible to implement it as a stable sort. True or False? These …

Member Avatar for Mirty
0
291
Member Avatar for vegaseat

Sometimes when you get a large check from your employer, the value is written out in words. I get those all the time of course. So I wrote this little Python code to convert an integer value to english words. Numbers as high as 999 vigintillion can be used. In …

Member Avatar for Abdullahi_2
3
11K
Member Avatar for kiyo_1

i put this code to now how to enter the name name = raw_input('eter your name') name = {} but i want the name that i input it please replied fast

Member Avatar for pty
0
94
Member Avatar for kiyo_1

i put this code name = raw_input ('please enter your name-->') print 'hello ' + name age = raw_input ('enter you age-->') if age < 5: print 'what the...how did you understand on me' elif age < 18: school = raw_input ('in wich school you are') print "I don't care" …

Member Avatar for Gribouillis
0
221
Member Avatar for Katarína_1

Hi, 1. I would like to ask how can I adjust array.csv like this: ,,,-00.000146400000, 0.08000, ,,,-00.000146200000, 0.00000, ,,,-00.000146000000, 0.00000, ,,,-00.000145800000, 0.00000, so I can have in first column -00.000146400000 and in second column 0.08000? (thanks, I am begginer). 2. How can I pick out information(number) from 20 separate files …

Member Avatar for Gribouillis
0
240
Member Avatar for john_beginner

Hello All, I am new in this language and want to access the run time value In other words, I want make a program in which ask the value from User like scanf() function in C and cin>> function in Cpp So is there any function or method by which …

Member Avatar for Reverend Jim
0
21K
Member Avatar for The Last

Hello guys, hope you all fine,, I have a problem when coding using python and opencv. My project is to track the ball in model soccer pitch using raspberry pi camera. I want the camera to track the ball and give an alert when the ball crosses the boundaries of …

Member Avatar for rproffitt
0
600
Member Avatar for Christine_7

I'm currently working on multithreading with PyAudio and Pygame, but when I try to run the audio, I get an error saying "OSError: [Errno -9996] Invalid output device (no default output device)." So far I've tried these on Terminal: >>> import pyaudio >>> pa = pyaudio.PyAudio() >>> pa.get_default_input_device_info() {'name': 'Built-in …

Member Avatar for rproffitt
0
5K
Member Avatar for vegaseat

Another application of Python module base64, this time to embed midi music data in your program. You also need the module pygame to execute this Python code. Enjoy the music!

Member Avatar for Rufus_1
5
12K
Member Avatar for gunjan_3

This is what I have: When I try to do this, it shows me an error: IndexError: list index out of range Could someone help? with open(os.path.join(path, file.replace(".root", ".txt")), 'r') as f: lines = f.readlines() htemp = TH1D(name, name, nBins, eMin, eMax) for i in range(len(lines)): htemp.SetBinContent(i + 1, float(lines[i])) …

Member Avatar for Gribouillis
0
274
Member Avatar for ruwach

Hey there. i want to set a variable to represent the last line of a text file how do i do that? or even better, how do i create a list of the lines of a text file? any suggestions?

Member Avatar for gunjan_3
0
63K
Member Avatar for dusk2dawm

import sqlite3 datafile = 'XZ704.DB' datadir = '/full_path_to/SQLITE_FILES/' db = datadir+datafile conn = sqlite3.connect(db) cur = conn.cursor() cur.execute("SELECT * FROM Airports LIMIT 1") --- OperationalError: no such table: Airports --- That works fine in a terminal but for some reason python 2.7 no like. I have tried full path, relative …

Member Avatar for rproffitt
0
24K
Member Avatar for RAZ_2

I am going to find out all messengers such as: WhatsApp, viber, Line, Telegram, instagram, Kik, facebook, And others that are Registered with a specific Phone Number. is there any way to do that in python? remember that I have the phone number but want to figure out the messengers …

Member Avatar for RAZ_2
0
272
Member Avatar for Christian_9

The end goal is to create a program that runs when my hard drive is plugged into a computer. This program will attempt to verify that the user is me through username and password. Upon correct input, the program will allow access to the files on the hard drive. Incorrect …

Member Avatar for rproffitt
0
297
Member Avatar for wai.yan.9678

A. Write a triangle solver that takes 3 inputs consisting of angles in degrees and length of sides in arbitrary units and, if possible (your program has to determine this), supplies all other angles and side lengths. There will be either 0 triangles, 1 triangle, 2 triangles or an infinite …

Member Avatar for JamesCherrill
0
28K
Member Avatar for dhani09

Hello, I have this home work question to be solved on a cloud ide: Create a class called ShoppingCart. Create a constructor that takes no arguments and sets the total attribute to zero, and initializes an empty dict attribute named items. Create a method add_item that requires item_name, quantity and …

Member Avatar for Emma Etigu
0
1K
Member Avatar for Moses_4

We are going to simulate a seat reservation program (think airlines seats). The plane has NUM_ROWS rows, and each row has NUM_SEATS seats (form A on). For this assignment, set NUM_ROWS = 6, and NUM_SEATS = 5. Make sure you use these two constant variables in the program.

Member Avatar for rproffitt
0
1K
Member Avatar for Fitzwilliam_1

Two bank account: current and saving. User has to be asked to choose one, then withdraw money. How can I do a decrement of the balance each time I loop in this function?? if balance = 10 euro , withdraw 5 so remaining is 5. User is asked to quit …

Member Avatar for James Paul
0
231
Member Avatar for Vokeh

#this program calculates the area of a right triangle #ask for input b=input('Enter the triangle base:') h=input('Enter the triangle height:') #Calculate and print area Area=(b*h)/2 Print '\n The base is '+str(b) + 'units' Print 'The height is 'str(h) + 'units' Print '\n The area is 'str(area + 'units'

Member Avatar for ddanbe
0
128
Member Avatar for Fitzwilliam_1

Car Rental will rent cars to their customer. They have the potential to rent either petrol, diesel, electric, or hybrid cars. They have initially 40 cars in their rental pool made up of 50% petrol, 20% diesel, 10% electric and 20% hybrid. When a car is not rented it is …

Member Avatar for Fitzwilliam_1
0
2K
Member Avatar for vegaseat

You can put an image and text on a Tkinter button widget. This small code shows you how. The GIF image file you want to use for the button should be in the working directory, or you have to give it the full path. Incorporate the Python Image Library (PIL) …

Member Avatar for neon_3
1
23K
Member Avatar for Rajan_8

I am doing a mini project on Caesar cipher, I found one program but can't understand the 29th line "key = -key". Please help me. # Caesar Cipher MAX_KEY_SIZE = 26 def getMode(): print('Do you wish to encrypt or decrypt a message?') print("'e' for encrypt and 'd' for decrypt") while …

Member Avatar for Rajan_8
0
694
Member Avatar for mile_1

Can anyone please help me to convert the Pseudo code to python code? receiveFile () { lastblock := 0 newblock := 0 ; repeat repeat event := getFrameFromUDP(m) ; case event of data : newblock := getBlockNoFromFrame(m) ; transmitAckOverUDP(newblock) | timeout: transmitAckOverUDP(lastblock) esac until newblock==lastblock+1 ; lastblock = newblock ; …

Member Avatar for rubberman
0
406
Member Avatar for Neethu_1

1) While working dates, when and why the local time and universal times are used? 2) Which multi-threaded program is recommended for reducing CPU usage? Why?

Member Avatar for Reverend Jim
0
155
Member Avatar for S._1

Hello everyone, I'm pretty new to python and I have found this code https://www.daniweb.com/programming/software-development/code/260268/restart-your-python-program to restart a python program. I have developed a little program and applied this function to it. By pressing a Button the function `resize()` is being called which triggers the `restart_program()` function. But when I start …

Member Avatar for Gribouillis
0
2K
Member Avatar for vegaseat

Just a relatively simple calculator using the Tkinter GUI. It has a few nice features such as correcting division by an integer (for older Python versions), error trapping, to and from memory buttons, and an editable display. The editable display allows you to backspace mistakes, and also to enter things …

Member Avatar for Charles_24
5
10K
Member Avatar for Mirty

python programming Your job for this question is to use Python turtle to draw any picture you'd like, making sure to meet the following requirements: Your code must use at least 1 if-statement, prompting the user to decide between 3 choices (e.g. colours, shapes, sizes, or anything else you'd like) …

Member Avatar for rproffitt
0
392
Member Avatar for long5001

Hi, I am trying to write a simple script that reads a file for two time stamps and then finds the delta. However, I can't get passed converting the time strings to datetime objects. I haven't done any coding since college and I everything I've read says this code should …

Member Avatar for long5001
0
974
Member Avatar for Vanessa_1

I need to make this python code to only take one parameter. Right now it takes multiple. def get_list(): return [input("Please enter a string: ") for i in range(int(input("Please enter the number of strings you want to input\n")))] def longest(lst): return max(lst, key = len) def alpha(lst): return [e for …

Member Avatar for Gribouillis
0
347
Member Avatar for paul_52

Hi there I am new to python. is there a program i could use to make a Clock with day and date in big fonts to help my gran with memory loss. regards Paul.

Member Avatar for paul_52
0
327
Member Avatar for zac202020

I am new to the forums and I am creating a Area Calculator for extra credit for a class I am in, but I am running into some problems. I have the program coded out the way it needs to operate I just can't seem to get it to loop …

Member Avatar for Gribouillis
0
4K
Member Avatar for Gribouillis

This snippet defines a function restart_program() which restarts your python program from within your python program.

Member Avatar for Gribouillis
5
75K
Member Avatar for Tcll

**Usage:** Provides a secure frontend object with restricted access to attributes of the backend object.

Member Avatar for Gribouillis
0
442
Member Avatar for Nether_1

I'm writing a python program that will search for a password that is the first piece in a string. I'm using raw_input() to do it, and here's what the code is like list = ['Nether\n'] password = list[0] print password if raw_input('Please Enter Password: ') == password: print "Successful" This …

Member Avatar for Gribouillis
0
372
Member Avatar for ayushi_3

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 where argv is imported. Although, sounds simple but still not able to understand the concept behind. I would like to …

Member Avatar for hastings.george.5
0
217
Member Avatar for Saif_7
Member Avatar for Estermont
Member Avatar for Dani
0
218
Member Avatar for dinilkarun

Hi, I am trying to open a large excel file (.xlsx) to ad some rows of data from another excel file. However, due to the size of the destination file i am getting the memory error. I tried the below, however when i create the worksheet object it is creating …

Member Avatar for ddanbe
0
2K

The End.