Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Looking for help with python

DoogleGrand
 Share

So in school we're making a Automated readability index and i'm having some trouble with getting the provided formula to work.
Reading age of text = 4.71 × (Characters/Words)+ 0.5 × (Words/Sentences)– 21.43

I have this so far and was wondering if i could have some help.

#password for authorization
userName = input("""Welcome to the Asterisk school's automated reading index.
Please enter your name: """)
password = "123"
print("Welcome to the Reading index " + userName, """-- where we test your reading ability!""")
password = input("Please enter the password: ")
if password == "123":
    print("Access granted")
else:
    print("Please try again or contact the system administrator")

#this is where all the books will be stored
harryPotter = ("""Mr. and Mrs. Dursley, of number four, Privet Drive, were proud\n to say that they were perfectly normal, thank you very much. They were\n the last people you'd expect to be involved in anything strange or mysterious,\n because they just didn't hold with such nonsense""")
jamesAndTheGiantPeach = ("""When James accidentally drops some magic crystals by the old\n peach tree, strange things start to happen. The peach at the top of the\n tree begins to grow, and before long it's as big as a house. When James\n discovers a secret entrance way into the fruit and crawls inside, he meets\n wonderful new friends--the Old-Green-Grasshopper, the dainty Ladybug\n and the Centipede of the multiple boots.""")
diaryOfAWimpyKid = ("""First of all, let me get something straight: This is a JOURNAL \nnot a diary. I know what it says on the cover, but \nwhen Mom went out to buy this thing I SPECIFICALLY told\n her to get one that didn't say "diary" on it \nGreat. All I need is for some jerk to catch me \ncarrying this book around and get the wrong idea.""")
catInTheHat = ("""The sun did not shine \nit was too wet to play\n so we sat in the house\n all that cold, cold, wet day.""")
theLorax = (""" At the far end of town\nwhere the Grickle-grass grow\nsand the wind smells slow-and-sour when it blows\nand no birds ever sing excepting old crows\nis the Street of the Lifted Lorax\nAnd deep in the Grickle-grass, some people say\nif you look deep enough you can still see, today\nwhere the Lorax once stood\njust as long as it could\nbefore somebody lifted the Lorax away\nWhat was the Lorax\nAnd why was it there\nAnd why was it lifted and taken somewhere\nfrom the far end of town where the Grickle-grass grows\nThe old Once-ler still lives here\nAsk him. He knows.""")
theHobbit = ("""In a hole in the ground there lived a hobbit. Not a nasty,\n dirty, wet hole, filled with the ends of worms and an oozy smell, nor\n yet a dry, bare, sandy hole with nothing in it to sit down on or to eat:\n it was a hobbit-hole, and that means comfort.""")
theLordOfTheRings = ("When Mr. Bilbo Baggins of Bag End announced that he would\n shortly be celebrating his eleventy-first birthday with a party of\n special magnificence, there was much talk and excitement in Hobbiton.")
#using ascii art cause it looks cool
print("""
  _____ _                                    _                 _    _ 
 / ____| |                                  | |               | |  | |
| |    | |__   ___   ___  ___  ___    __ _  | |__   ___   ___ | | _| |
| |    | '_ \ / _ \ / _ \/ __|/ _ \  / _` | | '_ \ / _ \ / _ \| |/ / |
| |____| | | | (_) | (_) \__ \  __/ | (_| | | |_) | (_) | (_) |   <|_|
 \_____|_| |_|\___/ \___/|___/\___|  \__,_| |_.__/ \___/ \___/|_|\_(_)""")
#i wasnt sure how to make all letters recognised as a capital
choice = input("""\n A:Harry Potter \n B:James and the giant peach\n C:Diary of a wimpy kid \n D:Cat in the hat \n E:The Lorax \n F:The lord of the rings
 G:The Hobbit \n """)
#this is where the right text is selected according to the users request
if choice == "a":
    print(harryPotter)
elif choice == "b":
    print(jamesAndTheGiantPeach)
elif choice == "c":
    print(diaryOfAWimpyKid)
elif choice == "d":
    print(catInTheHat)
elif choice == "f":
    print(theLordOfTheRings)
elif choice == "g":
    print(theHobbit)
elif choice == "e":
    print(theLorax)
else:
    print("\nThis text doesn't exist.")

#this is where their reading age is printed
#the answer that would be printed below is the number that comes out after the calculation is done


    
input("\n\nPress enter to exit")
 

Anyway thanks in advance and if you don't have anything constructive to say don't bother commenting please. And i'm using version 3.6.4 if anyone wants to know

Link to comment
Share on other sites

Link to post
Share on other sites

You should format your code when posting it in a forum. This is true pretty everywhere (reddit, stackoverflow, here, etc.)
 

#password for authorization
userName = input("""Welcome to the Asterisk school's automated reading index.
Please enter your name: """)
password = "123"
print("Welcome to the Reading index " + userName, """-- where we test your reading ability!""")
password = input("Please enter the password: ")
if password == "123":
    print("Access granted")
else:
    print("Please try again or contact the system administrator")

#this is where all the books will be stored
harryPotter = ("""Mr. and Mrs. Dursley, of number four, Privet Drive, were proud\n to say that they were perfectly normal, thank you very much. They were\n the last people you'd expect to be involved in anything strange or mysterious,\n because they just didn't hold with such nonsense""")
jamesAndTheGiantPeach = ("""When James accidentally drops some magic crystals by the old\n peach tree, strange things start to happen. The peach at the top of the\n tree begins to grow, and before long it's as big as a house. When James\n discovers a secret entrance way into the fruit and crawls inside, he meets\n wonderful new friends--the Old-Green-Grasshopper, the dainty Ladybug\n and the Centipede of the multiple boots.""")
diaryOfAWimpyKid = ("""First of all, let me get something straight: This is a JOURNAL \nnot a diary. I know what it says on the cover, but \nwhen Mom went out to buy this thing I SPECIFICALLY told\n her to get one that didn't say "diary" on it \nGreat. All I need is for some jerk to catch me \ncarrying this book around and get the wrong idea.""")
catInTheHat = ("""The sun did not shine \nit was too wet to play\n so we sat in the house\n all that cold, cold, wet day.""")
theLorax = (""" At the far end of town\nwhere the Grickle-grass grow\nsand the wind smells slow-and-sour when it blows\nand no birds ever sing excepting old crows\nis the Street of the Lifted Lorax\nAnd deep in the Grickle-grass, some people say\nif you look deep enough you can still see, today\nwhere the Lorax once stood\njust as long as it could\nbefore somebody lifted the Lorax away\nWhat was the Lorax\nAnd why was it there\nAnd why was it lifted and taken somewhere\nfrom the far end of town where the Grickle-grass grows\nThe old Once-ler still lives here\nAsk him. He knows.""")
theHobbit = ("""In a hole in the ground there lived a hobbit. Not a nasty,\n dirty, wet hole, filled with the ends of worms and an oozy smell, nor\n yet a dry, bare, sandy hole with nothing in it to sit down on or to eat:\n it was a hobbit-hole, and that means comfort.""")
theLordOfTheRings = ("When Mr. Bilbo Baggins of Bag End announced that he would\n shortly be celebrating his eleventy-first birthday with a party of\n special magnificence, there was much talk and excitement in Hobbiton.")
#using ascii art cause it looks cool
print("""
  _____ _                                    _                 _    _ 
 / ____| |                                  | |               | |  | |
| |    | |__   ___   ___  ___  ___    __ _  | |__   ___   ___ | | _| |
| |    | '_ \ / _ \ / _ \/ __|/ _ \  / _` | | '_ \ / _ \ / _ \| |/ / |
| |____| | | | (_) | (_) \__ \  __/ | (_| | | |_) | (_) | (_) |   <|_|
 \_____|_| |_|\___/ \___/|___/\___|  \__,_| |_.__/ \___/ \___/|_|\_(_)""")
#i wasnt sure how to make all letters recognised as a capital
choice = input("""\n A:Harry Potter \n B:James and the giant peach\n C:Diary of a wimpy kid \n D:Cat in the hat \n E:The Lorax \n F:The lord of the rings
 G:The Hobbit \n """)
#this is where the right text is selected according to the users request
if choice == "a":
    print(harryPotter)
elif choice == "b":
    print(jamesAndTheGiantPeach)
elif choice == "c":
    print(diaryOfAWimpyKid)
elif choice == "d":
    print(catInTheHat)
elif choice == "f":
    print(theLordOfTheRings)
elif choice == "g":
    print(theHobbit)
elif choice == "e":
    print(theLorax)
else:
    print("\nThis text doesn't exist.")

#this is where their reading age is printed
#the answer that would be printed below is the number that comes out after the calculation is done


    
input("\n\nPress enter to exit")

 

 

Also, can you be more specific on how this isn't working? You want to help the people you're asking as much as possible, not just throw code at them and ask them to fix it without guiding them on what might be the problem. It doesn't look like you currently have an attempt at using the forumula. Can you give it a shot and let us now where you get stuck?

Gaming build:

CPU: i7-7700k (5.0ghz, 1.312v)

GPU(s): Asus Strix 1080ti OC (~2063mhz)

Memory: 32GB (4x8) DDR4 G.Skill TridentZ RGB 3000mhz

Motherboard: Asus Prime z270-AR

PSU: Seasonic Prime Titanium 850W

Cooler: Custom water loop (420mm rad + 360mm rad)

Case: Be quiet! Dark base pro 900 (silver)
Primary storage: Samsung 960 evo m.2 SSD (500gb)

Secondary storage: Samsung 850 evo SSD (250gb)

 

Server build:

OS: Ubuntu server 16.04 LTS (though will probably upgrade to 17.04 for better ryzen support)

CPU: Ryzen R7 1700x

Memory: Ballistix Sport LT 16GB

Motherboard: Asrock B350 m4 pro

PSU: Corsair CX550M

Cooler: Cooler master hyper 212 evo

Storage: 2TB WD Red x1, 128gb OCZ SSD for OS

Case: HAF 932 adv

 

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share


×