I am having some difficulties in producing the correct code for a simple
binary to decimal conversion program. The arithmetic I want to use is the
doubling method - so if I wanted to get the decimal equivalent of 1001, I
would start with multiplying 0 * 2 and adding the left most digit. I would
the
Thanks for clearing that up. I knew it was much simpler than I was trying to
make it I just couldn't quite see the logic that I needed for the problem
clearly. Thanks for the elegant code.
On Mon, Mar 9, 2009 at 10:53 PM, Moos Heintzen wrote:
> You're making it more complicated than it needs to.
myinput = raw_input("Please enter a binary real number: ")
myinput = myinput.split(".")
binstr1 = myinput[0]
binstr2 = myinput[1]
decnum1 = 0
decnum2 = 0
for i in binstr1:
decnum1 = decnum1 * 2 + int(i)
for k in binstr2:
decnum2 = decnum2 * 2 + int(k)
print "\nThe binary real number
Mar 29, 2009 at 10:46 PM, John Fouhy wrote:
> 2009/3/30 Chris Castillo :
> > that is what I have so far but I need to create a condition where I need
> > only 10 sufficient numbers from the variable decnum2. I know I need
> > something like
> > if len(decnum2) > 11:
>
I need some help converting the fractional (right side of the decimal) to
base 10.
I have this but it doesn't work
mynum = raw_input("Please enter a number: ")
myint, myfrac = mynum.split(".")
base = raw_input("Please enter the base you would like to convert to: ")
base = int(base)
mydecfrac = 0
f
see:
number = 234
mysum = 0
for digit in range(len(number) -1, -1, -1):
mysum = (mysum) * (1/base) + int(number[digit])
On Sun, Apr 5, 2009 at 6:25 PM, Alan Gauld wrote:
>
> "Chris Castillo" wrote
>
> I need some help converting the fractional (right side of the decima
at 7:53 AM, Dave Angel wrote:
> Chris Castillo wrote:
>
> Message: 1
>> Date: Sun, 5 Apr 2009 15:36:09 -0500
>> From: Chris Castillo
>> Subject: [Tutor] base n fractional
>> To: tutor@python.org
>> Message-ID:
>><50e459210904051336v60df
I am trying to open a text file and read multiple lines containing the
following:
745777686,Alam,Gaus,CIS,15,30,25,15,5,31,15,48,70,97
888209279,Anderson,Judy,Math Ed,14,30,30,13,11,30,16,18,58,72
I want to ask the user for the student number, check to see if that
number is even valid and display
so how would I check to see if the student number entered by the user
matches one of the student numbers in the file and then display that
students info?
On 4/19/09, R. Alan Monroe wrote:
>
>> gradesfile = open("grades.dat", "r
>> for lines in gradesfile:
>> [snip]
>> That's what I have so far bu
this worked for me fine.
#Author - Chris Castillo
#Created 4/19/09
#Program 6
import time
#Open and read text file with student information
gradesfile = open("grades.dat", "r")
time_acc = time.asctime()
#Ask user for student ID to lookup student information
sought_id = raw
I'm having some trouble reading multiple data types from a single text file.
say I had a file with names and numbers:
bob
100
sue
250
jim
300
I have a few problems. I know how to convert the lines into an integer but I
don't know how to iterate through all the lines and just get the integers
and
te:
> All lines that come back from a text file come back as strings. You can use
> string methods to detect the data like so:
> f = open('test.txt')
> lines = f.readlines()
> numbers = []
> strings = []
>
> for line in lines:
> if line.strip().isdigit():
BobPerfect score
On Fri, Jul 17, 2009 at 12:48 PM, bob gailer wrote:
> Chris Castillo wrote:
>
>> how would i go about adding the names to a dictionary as a key and the
>> scores as a value in this code?
>>
>>
>> # refactored for better use of Python, co
--
your output for this code should look like this inside the text file:
*Bowling Report
--
sueBelow average
billAbove average!
natBelow average
tomPerfect score!*
Thanks to everyone who helped me with t
*I'm supposed to be reading in names a grades from a text file like so:
*
Chris
100
89
76
0
Dave
56
45
30
23
10
0
Sara
55
76
78
60
0
*the 0 indicates that's the end of the student's grades and not an actual 0
number grade for the student. This is what my code looks like so far:*
from myFunctions
Okay I really need help with the program I am writing. I've can't seem to
figure out what I need to do and have tried several different methods.
I need to read in a text file in python that contains the following:
Student Name ( could be unknown amount in file )
Numeric Grade ( could be unknown
ya i was kind of in a hurry composing the email earlier. sorry for the
typos and misunderstanding. This is what I actually have.
grades = []
names = []
gradeTotal = 0
numStudents = 0
inputFile = open("input.txt", "r")
for line in inputFile:
if line.strip().isdigit():
grade = float(li
On 7/26/09, Dave Angel wrote:
> Chris Castillo wrote:
>> ya i was kind of in a hurry composing the email earlier. sorry for the
>> typos and misunderstanding. This is what I actually have.
>>
>> grades = []
>> names = []
>> gradeTotal = 0
>> numStuden
so I have a string:
1 4|-| 50 |_33+. I love [#ick3n 4nd ch3353. Don't you love +|_|2|\e7
\/\/1+# the |#a|-|i|_7?
and I am trying to turn it into english with the following code:
fileIn = open("encrypted.txt", "r").read()
def eng2leet(astring):
astring = astring.replace("4","a")
astri
On Mon, Jul 27, 2009 at 1:38 PM, J Sisson wrote:
> You need a deterministic algorithm for conversion. It's impossible
> (without analyzing the context of the word) to translate "|_|#" (it's either
> "lf" or "uh", but which?).
>
>
>
On Mon, Jul 27, 2009 at 2:08 PM, Dave Angel wrote:
> Chris Castillo wrote:
>
>> so I have a string:
>>
>> 1 4|-| 50 |_33+. I love [#ick3n 4nd ch3353. Don't you love +|_|2|\e7
>> \/\/1+# the |#a|-|i|_7?
>>
>>
>> and I am trying to turn
# Module demonstrates use of lists and set theory principles
def Unite(set1, set2): # evaluate 2 lists, join both into 1 new list
newList = []
for item in set1:
newList.append(item)
for item in set2:
newList.append(item)
newL
22 matches
Mail list logo