Python Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPython Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old December 6th, 2012, 10:07 AM
TrippyTheKid TrippyTheKid is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2012
Posts: 1 TrippyTheKid User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 55 m 58 sec
Reputation Power: 0
A little project help..

I'm really new to programming & I'm taking an entry level course right now.My professor gave us 2 projects here (below). Does anyone think they could find the time to help me out with these projects? I'm so confused & these are our last two projects and he won't be on campus anymore. I'm not asking anyone to do them for me, but guidance would help me a lot. Please & Thank you in advance.

1.)Write a program that will read an unknown number of bowlers and their bowling scores (with possible values from 1 to 300) from an external file called "bowlingscores.txt". The file will look similar to the following:
David
102
Hector
300
Mary
195
Jane
160
Sam
210

Output the bowlers’ names to an external data file called "bowlingaverages.txt". Next to each bowler's name, print a message dependent on their scores:
For perfect scores (equal to 300), output “perfect”
For those scores greater than the average score, output “above average”
For those below average, output “below average”
Your program must include at least one function (e.g., to calculate the average, to determine the appropriate message to print, etc.).


And,

2.)Your program needs to decode an encrypted text file called "encrypted.txt". The person who wrote it used a cipher specified in "key.txt". This key file would look similar to the following:

A B
B C
C D
D E
E F
F G
G H
H I
I J
J K
K L
L M
M N
N O
O P
P Q
Q R
R S
S T
T U
U V
V W
W X
X Y
Y Z
Z A

The left column represents the plaintext letter, and the right column represents the corresponding ciphertext.

Your program should decode the "encrypted.txt" file using "key.txt" and write the plaintext to "decrypted.txt".

Reply With Quote
  #2  
Old December 6th, 2012, 11:31 AM
b49P23TIvg's Avatar
b49P23TIvg b49P23TIvg is offline
Contributing User
Dev Shed Loyal (3000 - 3499 posts)
 
Join Date: Aug 2011
Posts: 3,460 b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level)b49P23TIvg User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 1 Month 2 Weeks 4 Days 6 h 56 m 42 sec
Reputation Power: 403
We covered this assignment a while ago. It's too much information---please write your own code.
__________________
[code]Code tags[/code] are essential for python code!

Reply With Quote
  #3  
Old December 6th, 2012, 11:39 AM
rrashkin's Avatar
rrashkin rrashkin is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2012
Location: 39N 104.28W
Posts: 97 rrashkin User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 15 h 26 m
Reputation Power: 2
Let's look at the first problem.
To read a text file, you have to open it:
fid1=open("bowlingscores.txt","r")

To write a text file, you have to open that, too:
fid2=open("bowlingaverages.txt","w")

It seems to me that you're going to want a list of the names and scores so I would initialize that:
lst1=[]

Normally (and in this case, too), you step through a file using the iterator quality of the file object:
for strLine in fid1:

Now, in your case, each line is just one thing so, after stripping off the linefeeds, you would append it to the list:
<indent>lst1.append(strLing.strip('\n'))

Now just for jollies, it's good practice to close the input file:
fid1.close()

Now lst1 has names and numbers (as strings) in succession. I would make those into a list of tuples (using list comprehension), each tuple being a (name, number) pair:
lst2=zip([i for i in lst1[::2]],[i for i in lst1[1::2]])

now each element of lst2 looks like: ("David","102)

Let's see if that gets you started on that one.


For the second one, I'd use a dictionary (actually, this is the very definition of a case for a dictionary). So just like before, you'd open the file. This time you initialize a dictionary:
dct1={}

Now, after reading each line and stripping the linefeeds, you want to add a dictionary entry like {'B':'A'} in the case of the first one. That is "if I read "B", that means "A". So now, as you read each strLine:
lsta=strLine.strip('\n').split()
dct1[lsta[1]=lsta[2]


again, see if that gets you started.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPython Programming > A little project help..

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap