473,698 Members | 2,508 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Python Mark book with multiple marks per student?

3 New Member
Expand|Select|Wrap|Line Numbers
  1. def markbook_list():
  2.  
  3.     names = []      
  4.     marks = []      
  5.  
  6.     while True:     
  7.         name = raw_input("Name: ")      
  8.  
  9.         if name == "exit":      
  10.             break
  11.         elif name == "print":     
  12.             print "Name" + "      " + "Mark"
  13.             for x in range(len(names)):
  14.                 print names[x] + "     " + marks[x]
  15.         else:
  16.             names.append(name)      
  17.             mark = raw_input("Mark: ")      
  18.             marks.append(mark)   
1)Write a markbook application to read in, store and print out the marks for students

I already did number 1 as you can see.
How would one change the code so that it prompts the user for multiple marks per student?
Jun 7 '12 #1
1 2552
dwblas
626 Recognized Expert Contributor
You would use another while loop and append marks to a list until the user enters "exit" or some character that exits the loop. You might possibly want to use a list of lists, i.e
[[name1, mark1, mark2],
[name2, mark1, mark2, mark3]] or a dictionary. The following is pseudo-code and will not work perfectly as is.
Expand|Select|Wrap|Line Numbers
  1.         else:
  2.              if len(interim_list):
  3.                  master_list.append(interim_list)
  4.              interim_list=[name]  ## redefine it as new name only      
  5.              #names.append(name)
  6.              mark = raw_input("Mark: ")      
  7.              interim_list.append(mark)   
Jun 7 '12 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
1243
by: scn | last post by:
does anyone know when the next edition of 'learning python' is due for release? thank you. scott
9
1817
by: santanu | last post by:
Hi all, I know a little python (not the OOP part) learnt by studying the online tutorial. Now I would like to learn it more thoroughly. I have access to 'Programming Python' which I liked (on flipping through the pages), but the problem is it deals only with version 2.0 of Phython.
3
2193
by: larsmtl | last post by:
Howdy all, Is there an easy way to return all items of an "HTML select multiple" even if they aren't highlighted? form=cgi.FieldStorage() form.getlist("box") only returns those that are selected.
12
2236
by: Raque | last post by:
Hello. I'm looking for a good C++ reference book. I learned C++ a year ago. It is very broad and I need something to refer to. Particularly about syntax (using -> versus ".", etc.), using classes, C++ functions, etc. Basically, a good overall C++ language reference. I need a reference book. Not a "begin from scratch" instruction book, unless there is one that is also a good reference. Also, does anyone know of any good standard...
3
1547
by: msnews.microsoft.com | last post by:
Hello All, In the "Find Dialog" (Ctrl-F) of the IDE there is an option called "Mark All". When I click "Mark All", this marks the occurences of my search text. How will I clear this mark? Thanks for your time.
2
1268
by: progman | last post by:
new to python. i work with db heavily. any good book for python + database?????
2
1939
by: Patrick Stinson | last post by:
Is it a correct to assume that you can use multiple instances of python altogether if each is loaded from a separate dll? For instance, if I write a couple of dll/so libs, and each has python statically linked in, is it safe to assume that since dlls use their own address space then each dll would have it's own GIL, and will therefore coexist safely within the same app? This is correct across all platforms, yes? I ask because I will be...
3
1136
by: David Moss | last post by:
Hopefully a service like this already exists and I just haven't found it yet. If not it could be an idea for some kind soul(s) to pick up and run with ;-) As someone who writes and releases Python modules for the community, I find it difficult to have a decent level of confidence in the efficacy of my code on platforms and Python versions other than those that I own or use regularly. My documentation states that I support Python 2.3 or...
1
2467
by: Dave067 | last post by:
Hi folks I am teaching myself Python by working through Hans Petter Langtangen's excellent book "Primer on Scientific Programming in Python". The exercises in chapter 4 of the book require the student to use Python with the freely downloadable tools MatplotLib and SciTools to plot graphs of mathematical functions. Despite downloading and installing numerous different versions of Python 2.x, MatPlotLib and SciTools, I am unable to find a...
0
8612
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9171
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9032
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8905
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7743
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5869
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4373
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4625
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2008
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.