- Upvotes Received
- 1
- Posts with Upvotes
- 1
- Upvoting Members
- 1
- Downvotes Received
- 1
- Posts with Downvotes
- 1
- Downvoting Members
- 1
19 Posted Topics
I have the following section of code that works perfectly when I run it as a .py file. When I convert it to a .exe using py2exe it appears that the linecache.getline() function is not working properly. I am able to create and write the .txt file fine, so I … | |
Hi I am fairly new at pyhton and I am trying to create a program to append a new row of raw input to the bottom of my existing .csv file. So far I have this: [CODE]import csv x=1 y=1 n=0 citiesx=[] citiesy=[] city_names=[] total=input("How many cities do you have? … | |
I have a list that looks similar to thisand is stored in a text file; last, first, code smith, john, test I cannot figure out why it is out of bounds. Where am I going wrong? is it in the split statement? import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.DataInputStream; import java.io.FileInputStream; … | |
I am getting a null pointer exception on line 36 of this code, I do not understand how any of my values are null because they should all be filled with data from the text document. What am I doing wrong? import java.io.BufferedReader; import java.io.DataInputStream; import java.io.FileInputStream; import java.io.InputStreamReader; public … | |
I have an assignment that I have been working on that is to modify an existing rock paper scissors program so that I ahve a method that sets the player name and a method that gets the player's name. I have created the methods however it does not allow me … | |
I have used snippets of code from various sources to compile the following code: import java.awt.*; import java.awt.image.BufferedImage; import java.io.*; import javax.imageio.ImageIO; import javax.swing.JFrame; import java.util.Calendar; public class ShowImage extends Panel { static Calendar cal = Calendar.getInstance(); //gets system time BufferedImage image; private static final String holidaysimages[] = { //declares … | |
import javax.swing.JOptionPane; public class Login{ public static void main(String[] args){ String username = JOptionPane.showInputDialog("What is the desired username?"); String password = JOptionPane.showInputDialog("What is the desired password?"); boolean unlock=false; while(unlock==false){ String usernameinput = JOptionPane.showInputDialog("What is the username?"); if(username==usernameinput){ String passwordinput = JOptionPane.showInputDialog("What is the password?"); if(passwordinput==password){ System.out.println("access granted"); unlock=true; }else{ System.out.println("denied"); … | |
I am working on a java application that will display an image and play a sound. It finds the current month and displays the appropriate information. Below is the code that I have been testing (that's why santa is in april) it will not work when trying to play wav … | |
I have these 2 classes: [CODE]import javax.swing.JOptionPane; public class Theatre2D { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub // declares an array of integers int[][] myTheatre2D; // allocates memory for 2*10 integers myTheatre2D = new int[2][10]; myTheatre2D[0][0] = 20; myTheatre2D[0][1] = … | |
I currently have this code: [CODE]import java.util.Random; import java.io.*; public class randomdwarf { public static void main(String[]args)throws IOException { String dwarves[]= {"Dopey", "Sneezy", "Happy", "Sleepy", "Grumpy", "Bashful", "Doc"}; Random generator = new Random(); int randomIndex = generator.nextInt( 7 ); System.out.println(dwarves[randomIndex]); Runtime.getRuntime().exec("H:\\Profile\\Desktop\\dwarves\\Doc.jpeg"); } }[/CODE] It is a very simple code that … | |
I have this code: [CODE] def closest(): citiescomp=[] distances=[] for i in range(0,len(city_names)-1): citiescomp.append([city_names[i], citiesx[i], citiesy[i]]) while True: try: targetx=int(raw_input('Please enter the x coordinate of the city you wish to target: ')) if targetx in range(0,1000): break else: print "Oops, it seems like you made a mistake. Try again by … | |
I have this code: [CODE]import csv from math import * distances=[] pos=0 tally=0 target_x=input("Please enter the X coordinate of the target city: ") target_y=input("Please enter the Y coordinate of the target city: ") count = sum(1 for row in csv.reader( open('cities.csv') ) ) cityname = csv.reader(open("cities.csv", "rb")) citynames = [] … | |
I have this code: [CODE]def welcome(): '''========Welcome to Jaron's======= ====Video Game Rental Service====''' def menu(): while True: print '''0-\t Exit 1-\t Register 2-\t Log-in 3-\t Browse 4-\t Read-me''' try: menu_choice=int(raw_input('Please make a selection by number: ')) global menu_choice break except ValueError: print "Oops, it seems like you made a mistake. … | |
I have this code: [CODE]import csv tally=0 i=0 n=1 numb=2 count = sum(1 for row in csv.reader( open('cities.csv') ) ) cityname = csv.reader(open("cities.csv", "rb")) citynames = [] citynames.extend(cityname) for data in citynames: citynames.append(data[0]) tally+=1 if tally>=count: break tally=0 cities_x = csv.reader(open("cities.csv", "rb")) cities_list_x = [] cities_list_x.extend(cities_x) names = [] for … | |
Currently I am making code to be used to make my playing of an online conquest video game easier. The first program the user would run is the initialize program. This is how the program looks: [CODE] #initialize import csv x=1 y=1 n=0 citiesx=[] citiesy=[] city_names=[] total=input("How many cities do … | |
I have this psuedocode: [QUOTE]FUNCTION initialize FOR row = 1 to num_items get random number for the list ENDFOR ENDFUNCTION initialize FUNCTION show FOR row = 1 to num_items show output: list(row) ENDFOR ENDFUNCTION show FUNCTION sort FOR pass = 1 to num_items posn = 1 sorted = True WHILE … | |
[CODE]#created by Jaron Graveley #April 26th, 2011 #This program completes reservations for Jon Von Poechman’s airline in an easy to use program #variable list: #i=counter used to limit the number of seats present on the diagram #n= counter to display the row number on the diagram #num_booked=counts the number of … | |
So I have a program I am making but I need to make it more efficient, is there any way to condernse the following code into a more compact and efficient code? [CODE]r1p1=o r1p2=o r1p3=o r1p4=o r2p1=o r2p2=o r2p3=o r2p4=o r3p1=o r3p2=o r3p3=o r3p4=o r4p1=o r4p2=o r4p3=o r4p4=o r5p1=o r5p2=o … | |
I have a code designed to show the different spaces a knight can move to in a standard chess game. It needs to be a function created that outputs the possible spaces in tuples. I can't figure out how to make the output in tuples and I would appreciate it … |
The End.