Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8837785
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T09:48:59+00:00 2026-06-14T09:48:59+00:00

I need to make a table that pulls one or more person’s name and

  • 0

I need to make a table that pulls one or more person’s name and scores at various games from a text file, then find the average, minimum and maximum of each person’s scores and display them.

EDIT-here is my current code:

    while name!='':
    floor=text_file.readline().rstrip()
    rings=text_file.readline().rstrip()
    p_bars=text_file.readline().rstrip()
    p_horse=text_file.readline().rstrip()
    h_bar=text_file.readline().rstrip()


    floor_int=int(floor)
    rings_int=int(rings)
    p_bars_int=int(p_bars)
    p_horse_int=int(p_horse)
    h_bar_int=int(h_bar)

    score_sum=floor_int+rings_int+p_bars_int+p_horse_int+h_bar_int
    avg=score_sum/5    

how would I be able to do math with the lines that have numbers and exclude the lines that have names?

EDIT: running that code gives me this:
TypeError: Can’t convert ‘float’ object to str implicitly

any ideas?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T09:49:01+00:00Added an answer on June 14, 2026 at 9:49 am

    Assuming ‘rings’ is a line that has a number, you can add all those by creating int or float objects, for example:

    rings=rings.rstrip('\n')
    rings_int = int(rings)
    sum_of_rings += rings_int
    

    If there is a mix of numbers and other text within a line, use a regular expression to pull out the number part first:

    import re
    
    m = re.search('\d+', rings)
    if m:
        rings_int_str = m.group()
        rings_int = int( rings_int_str )
        sum_of_rings += rings_int
    

    I use a lot of individual variables to clarify this, but the steps can be combined, for example:

    sum_of_rings += int( text_file.readline() )
    

    P.S. If you are getting that error, it is probably in a print statement where you are trying to print avg without converting it to a string somehow. Either of these works:

    avg=score_sum/5.0
    print "%f" % (avg)
    print str(avg)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to make sure that the height of the header of table is
How can I make a mysql dump for table from a query? I need
I need to make a query output Using table, I want the following report,
i need help on how to make fixed textview size in table layout. say
I need to make a column unique in one of our database tables, and
I put together a simple script that pulls the product name, category name and
I have two database tables. One table stores data for a commitment that a
I need to make every two rows of my table grey and I would
I need to build a SQLite table that will consist of the following columns:
I have one table in my database that I want to update each year.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.