import csv import xlwt import os import sys #import openpyxl # Look for input file in same location as script file: inputfilename = os.path.join(os.path.dirname(sys.argv[0]), 'book2.txt') # Strip off the path basefilename = os.path.basename(inputfilename) # Strip off the extension basefilename_noext = os.path.splitext(basefilename)[0] # Get the path of the input file as the target output path targetoutputpath = os.path.dirname(inputfilename) # Generate the output filename outputfilename = os.path.join(targetoutputpath, basefilename_noext+'.xls') # Create a workbook object workbook = xlwt.Workbook() # Add a sheet object worksheet = workbook.add_sheet(basefilename_noext, cell_overwrite_ok=True) # Get a CSV reader object set up for reading the input file with tab delimiters datareader …

Member Avatar
+0 forum 0

How can I locally save an image using its URL address?

Member Avatar
Member Avatar
+1 forum 4

What is the difference between the term Shallow copy and Deep?

Member Avatar
Member Avatar
+0 forum 4

Initially, I've a simple program to print out the whole output to the console. **Initial Code to display output in the console only** import os, subprocess print("1. Before") os.system('ver') subprocess.run('whoami') print('\n2. After') **Output in console** 1. Before Microsoft Windows [Version 10] user01 2. After Then, I decided to have a copy on a log file (log.txt) too while maintaining the original output to the console. So, this is the new code. import os, subprocess, sys old_stdout = sys.stdout log_file = open("log.txt","w") sys.stdout = log_file print("1. Before") # This appear in message.log only, but NOT in console os.system('ver') # This appear …

Member Avatar
Member Avatar
+0 forum 1

You must then use a loop (for or while) to find the sum of all the numbers in the geometric sequence of 3 less than N. The geometric sequence of 3 looks like this 1, 3, 9, 27, 81, 243, ... where you start with the number one and multiply the previous number by 3 to get the next number. add the sequences together to get answer

Member Avatar
Member Avatar
+0 forum 4

Hi How to read the second line in text file(MyData,txt) #MyData.txt line1 line2 line3 line4 line5 #read the second line f = open ("MyData.txt","r") for line in f: if line == 2: print line else: print "somthing wrong !" f.close()

Member Avatar
Member Avatar
+0 forum 1

I have a bank system that's using a tkinter class to run the program with a graphical user interface looking like this: LARGE_FONT = ("Verdana", 12) class BankSystemGUI(tk.Tk): def __init__(self, *args, **kwargs): tk.Tk.__init__(self, *args, **kwargs) container = tk.Frame(self) container.pack(side="top", fill="both", expand=True) container.grid_rowconfigure(0, weight=1) container.grid_columnconfigure(0, weight=1) self.frames = {} for F in (LoginPage, PageOne): frame = F(container, self) self.frames[F] = frame frame.grid(row=0, column=0, sticky="nsew") self.show_frame(LoginPage) def show_frame(self, cont): frame = self.frames[cont] frame.tkraise() class LoginPage(tk.Frame): def __init__(self, parent, controller): tk.Frame.__init__(self, parent) label_1 = tk.Label(self, text="Welcome to the Python Bank System", font=LARGE_FONT) label_1.pack(pady=10, padx=10) label_2 = tk.Label(self, text="~~~~~~~~~~~~~~~~~~~~~~~~~~~~~", font=LARGE_FONT) label_2.pack(pady=10, padx=10) button1 = …

Member Avatar
Member Avatar
+0 forum 1

i am here ![Screen_Shot_2018-12-28_at_6_47_38_PM.png](/attachments/large/4/237abffd6067e29aa8bd690c2c1a74ec.png) i want to merge all rowsof 3 rd col so that output looks like... end result should be.... ![Screen_Shot_2018-12-28_at_6_49_34_PM.png](/attachments/large/4/92adfc647020ab9265f7d7248758c82f.png)

Member Avatar
Member Avatar
+0 forum 1

Hello everybody, I want to convert python to c but ı did not find any converter. Is it possible to convert

Member Avatar
Member Avatar
+0 forum 1

What are the different file-processing modes with Python?

Member Avatar
Member Avatar
+0 forum 2

Is it appropriate to say that a function not having a return statement is valid?

Member Avatar
Member Avatar
+0 forum 5

Why the part will not have add() and remove() ways whereas Jcomponent Have add() And Remove() ways?

Member Avatar
Member Avatar
+0 forum 2

i want to display this number pattern in python, help me! 9 89 789 6789 56789 456789 3456789 23456789 123456789

Member Avatar
Member Avatar
+0 forum 5

Can anyone help me with the process of making an executable python script in Unix?

Member Avatar
Member Avatar
+0 forum 4

Hi, i have a textfile with a string in it. The string is built like this: test =""" [ "this is a text and its supposed to contain every possible char." ], [ "like *.;#]§< and many more." ], [ "plus there are even newlines in it." ]""" I want to parse out each text in between the square brackets and the quotes. So my desired output would be a list like the following: `['this is a text and its supposed to contain every possible char.', 'like *.;#]§< and many more.', 'plus there are even newlines in it.']` I tried …

Member Avatar
Member Avatar
+0 forum 6

What function should I use to convert JSON into Python data?

Member Avatar
Member Avatar
+0 forum 2

So I'm trying to create a UI that allows multiple buttons in the same window. All of the are toggles to control GPIO outputs to control relays. I've managed to get them to all work individually in their own files, but when put into the same file is all on or all off. There is only 4 toggles for now, as a demonstration for my boss, but there will be many more on the final product.` Below is the code I've come up with so far. (keep in mind I only started learning Python and coding in general yesterday) I'm …

Member Avatar
Member Avatar
+1 forum 4

I've seen the following code for binding the Escape Key to a Tkinter GUI: import Tkinter as tk def exit(): root.destroy() root = tk.Tk() root.bind("<Escape>", exit) root.mainloop() However, when I add this to my GUI program, I don't get a response when Esc key is pressed. It does nothing. Any suggestions?

Member Avatar
Member Avatar
+0 forum 1

what are the different relational operators in python?

Member Avatar
Member Avatar
-1 forum 3

Is it possible to store a certain function as a variable? If not, is it okay to make a class, and define a function. Store the class as the variable and invoke that function?

Member Avatar
Member Avatar
+1 forum 7

Hello, I want help in scrapy i want scrap this page full source code as Inspect Element mode https://www.contechlighting.com/en/products/recessed-lighting/led when i use this code import scrapy class TEST(scrapy.Spider): name = "quotes" start_urls = [ 'https://www.contechlighting.com/en/products/recessed-lighting/led#t=Products&sort=%40wcs_site_tree_rank ascending&layout=card', ] def parse(self, response): filename = 'contechlighting.html' with open(filename, 'wb') as f: f.write(response.body) get html source code and the site use dynamic content with javascript and i cant see the product items and results number on the top how can get full source code with scapy as appear on Inspect Element on firefox ? can any one edit on my code to do this …

Member Avatar
Member Avatar
+0 forum 1

Can anyone point me in the right direction? I have tried wxlistctrl, ultimatelistctrl and objectlistview, none seem to be able to allow the displayed list to be re-ordered by moving (drag n dropping) an item. Thanks.

Member Avatar
Member Avatar
+0 forum 1

hello, I am currently working on an assignment in my IPT class and I am trying to get questions from my questions box randomly. I am able to do the random function but I do not want them to repeat. My 'questions box' is a dictionary and I have also imported tkinter. Please do help as it is due soon. This is what I am currently doing to get random things: number = random.randint(0,len(Questions_Box)-1 q = Questions_Box[number] random.shuffle(Questions_Box)

Member Avatar
Member Avatar
+0 forum 2

Vending machine is a machine which dispenses goods/items such as snacks, soft drinks, chocolates, cookies, chips and other selected items to customers automatically, after the customer inserts currency or coins into the machine. The project is required to design, implement to simulate a vending machine. The program will work with item names, their prices, and the current number available in the machine. The machine should display different items. When the application starts, the vending machine will display each type of goods or items and number of items available in the machine. Each time the customer selects an item, the application …

Member Avatar
Member Avatar
-1 forum 1

Can you please help me with write a python program to read five scores and output the average score and also output the amount by which that score differes from the average. I have done the average part but I don't know how to get the difference of all the scores from average. Please help. Total_exam = 0 for n in range(5): score = float(input("Enter a score:")) Total_exam = Total_exam + score #for average calculation #using average formula to calculate average avg = Total_exam/5 print("The average score is", avg)

Member Avatar
Member Avatar
+0 forum 1

**hey guys, im trying to get this program done for class. this is the assignment:** For this assignment, you will write a program that uses a method called displayMenu to display a menu like the following: Enter 1 to convert a string to uppercase Enter 2 to convert a string to lowercase Enter 3 to count the number of words in a string Enter 4 to count the number of vowels in a string Enter 5 to exit After the user enters their choice, ask them to enter the string. Call the variable user_string, and use the len() method to …

Member Avatar
Member Avatar
+0 forum 1

Hi, I have been searching for freelance software developer on different websites for a while but failed to find him for the software I need. Been studying and researching a lot how could i come as close as possible to the solution i am looking for: what needs to be done is changes tracking (monitoring) of graphical widgets (Embed code) that contains speedometers. Similar to the one(s) behind the steering wheel in a car. Each speedometer contains different circular areas and what I want is to track (and get screen pop up alerts) when it graphically travels from one to …

Member Avatar
Member Avatar
+0 forum 12

Hi I have python code that can list all drive letters but now I need also list the name of drive letter (Label) and the size of hard drive like below! Ltr Label Size ---- ------ --------- C Windows 800 GB E Local Disk 200 GB F My Passport 500 GB Y Secret 1 GB import string from ctypes import windll def get_drives(): drives = [] bitmask = windll.kernel32.GetLogicalDrives() for letter in string.ascii_uppercase: if bitmask & 1: drives.append(letter) bitmask >>= 1 return drives if __name__ == '__main__': print (get_drives()) # On my PC, this prints ['A', 'C', 'D', 'F', 'H'] …

Member Avatar
Member Avatar
+1 forum 8

Hello, I need help on getting solution for the below python code. The code gives the required output which is that it dispaly number of prime number that user wants. if user inputs 4 Actual Output: 2, 3 , 5 , 7 The main question is that I do not have idea on how to give rank to those prime numbers. For Example: The 1st prime number is 2 The 2nd prime number is 3 The 3rd prime number is 5 The 4th prime number is 7 and so on. Can anyone please help to write the code to get …

Member Avatar
Member Avatar
+0 forum 1

Hi, I've been doing research on a career in coding/programming and now I'm very interested and motivated to learn it. I'm a complete beginner and limited financially at present. So I'm confused as to how to go about it. I love reading a lot and sitting on my laptop, so no problem with studying. I'm the type of person that likes to learn an important big wide subject in stages. To first get a decent background and understanding of it. Then to go deeper into it. Is the following way a good way to go about it? Go through books …

Member Avatar
Member Avatar
+2 forum 4

The End.