Have a homework assignment that requires I output 4 different floats to two decimal places.
This is what I have:
print '%.2f' % var1,'kg =','%.2f' % var2,'lb =','%.2f' % var3,'gal =','%.2f' % var4,'l'
Which is very unclean, and looks bad. Is there a way to make any float in that out put '%.2f'?
Note: Using Python 2.6.
...
ok, im new to this, but basically i have this problem, and im confused on how to go about it, any help would be great, sorry about not posint this before!.
The compilation was successful
The output should have been:
The club had 6 members.
and 4 had joined in March 2008
There are now just 2 members left.
This is what wa...
Hie guys i have this assignment where im supposed to extract headstone data from an inscription file (structured text file).From this file im supposed to extract the name of a deceased person, date of birth (or age) and also personal messages.The application should be able to analyse a raw text file and then extract information and displ...
I'm writing a Conway's life game for school. In the program I am having trouble with the arrays taking the values I am assigning them. At one point in the program they print out the value assigned to them (1) yet at the end of the program when I need to print the array to show the iterations of the game it shows an incredibly low number....
In my programming class, I don't understand what the value of printf("World") is (question my prof is asking)? What value does a printf have? He says it is 5, but I don't know why. Thanks.
...
I have two classes:
class Dog(object):
def __init__(self, name):
self.name = name
class Toy(object):
def play(self):
print "Squeak!"
I need to come up with a method called play(self, toy, n) for class Dog. It prints "Yip! " (with a space) followed by the output from toy.play on the same line. This happens n ti...
Hello
I am trying to create emulation of "Mine game"
suppose we have matrix
0 0 0 0
0 0 -1 0
0 0 0 -1
0 -1 0 -1
now each cell that not equal -1 should be represent numbers of mines
here code
for(int i=0;i
for(int j=0;j<N;j++)
if(box[i][j]!=-1)
{
switch (i)
{
case 0:
iLEFT=0;
iRIGHT=1;b...
Hello,
how can we export c# methods?
I hava a dll and I want to use its methods in the Python language with the ctypes module.
Because I need to use the ctypes module, I need to export the c# methods for them to be visible in Python.
So, how can I export the c# methods (like they do in c++)?
...
Hi, I'm stuck building the transition functions for this automaton.
I suppose I should stack a 1 for each a and unstack it for each b
The number of c's equals the number of ab pairs, so I think I should stack a 0 for each b I encounter. Thing is: how do I unstack 1s and add 0s at the same time?
...
For my implementation of tail shell command in Linux, I need to read certain amount of lines/bytes from the end of the file using stream input/output. Does anyone have suggestions how to do that? I suspect I need to open a file and pass some parameter to the ifstream constructor, but I don't know what exactly. Googling didn't find anythi...
Hey guys, I couldn't really think of what to call this error in the title, so here goes.
I'm starting an assignment where I have to read the contents of a file, perform some calculations and write the contents + the new calculations to a file.
I wrote the code to read in the file, and to right away write it into an output file to tes...
I am trying to create a class which has a private member that is an array. I do not know the size of the array and will not until the value is passed into the constructor. What is the best way to go about defining the class constructor as well as the definition in the .h file to allow for this variable size of the array?
...
So I am trying to write a code that opens a file and inside that file might be empty or contains the name of other files to open on each line. For example. 1.txt has 2.txt. on the first line and 3.txt on the second line. 2.txt is a empty file and 3.txt has 4.txt on the first line. I have to have an output that prints the files that the c...
how do i model a baseball game and players in OO?
...
Hello Everyone...
I'm having some difficulty having this code generate a number of permutations(orderings) on a string separated by commas ...I can do just a regular string and have the permutations work on just letters but it is a bit more difficult when doing it with words separated by the commas...
To have the program recognize the ...
Hello friends,
I have an arraylist which contains some objects and i have to get permutation of that objects?How can i do that?
Suppose MyList is an arraylist which contains 4 objects.
ArrayList myList = new ArrayList();
myList.Add(1);
myList.Add(2);
myList.Add(3);
myList.Add(4);
so arraylist count is 4 so i want 4!=24
I want 24 per...
iI am trying to write a recursive code that can convert a number to any base system. for example, the interger 10 into binary would convert to 1010
so far i have this but i'm having "None" in between my output. Can anyone help me with my code?
def convert(a,b):
add = a%b
if a<=1:
return a
else:
print(base(a/...
Hello
I have a project that needs to be changed..
right now i have a web page that posts to a jsp that calls a servlet that calls a "backend" using Tomcat.
I need to get take Tomcat off the scene.
What i want is when i POST, it calls directly the "backend"
Any suggestions on how can i accomplished that?
Thanks
Rev
...
The question reads: consider a 4-input boolean function that is asserted whenever exactly two of its inputs are asserted, construct its truth table, and then other parts for the question.
I don't want an answer i would like to solve this myself, i just want to know the meaning of assert and how to start with the truth table. Any help is...
Hi,
I have a logic question:
If I have: f(A,B,C,D) = M(4,7,8,11).D(1,2,13,14)
what would be the sum of products for that using k-map (please note that this is big-m and you have to find the answer in the sum of products)
I drew the k-map, the problem is, I can't find a way to cover the zeros without having to state 4 terms each with ...