Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Random Expression Creator
#1
Overall My program is good. But I am having trouble figuring out how to do a few things. I could really use some help. I need to know how to fix my parenthesis appearing above all the other text and make it display inside the expression as well as get rid of the "None" text appearing in my expression. The last thing is I don't know how to make my answer variable(line 43) = the answer to the expression. By the way, the outcome is when I took out line 43. Thank you for your help! Smile
import time
from tkinter import *
import random
answer_input = 0
answer = 0
sign_list = ['+','-','*','/']
power_list = ['P0', 'P1', 'P2', 'P3', 'P4', 'P5', 'P6', 'P7', 'P8',' ', 'SR0', 'SR1', 'SR2', 'SR3', 'SR4', 'SR5', ' ', ' ', ' ', ' ', ' ',]
Open_Parenthesis_list = random.randint(0, 1)
Open_Parenthesis_list2 = random.randint(0, 1)
Closed_Parenthesis = [')']
print("A random expression will be created that you must solve. *IMPORTANT: SR-Square Root, P2-Squared, P3-Cubed, SR2-Square root of, etc.")
print(' ')
Random_Number1 = random.randint(0, 100)
Random_Number2 = random.randint(0, 100)
Random_Number3 = random.randint(0, 100)
Random_Number4 = random.randint(0, 100)
Random_Number5 = random.randint(0, 100)
Random_Sign1 = random.choice(sign_list)
Random_Sign2 = random.choice(sign_list)
Random_Sign3 = random.choice(sign_list)
Random_Sign4 = random.choice(sign_list)
Random_Sign5 = random.choice(sign_list)
Random_Power1 = random.choice(power_list)
Random_Power2 = random.choice(power_list)
Random_Power3 = random.choice(power_list)
Random_Power4= random.choice(power_list)
Random_Power5 = random.choice(power_list)
PE = Open_Parenthesis_list
PE2 = Open_Parenthesis_list2
if PE == 1:
    ParenthesisA1 = print('(')
    ParenthesisB1 = print(')')
else:
    ParenthesisA1 = print(' ')
    ParenthesisB1 = print(' ')
if PE2 == 1:
    ParenthesisA2 = print('(')
    ParenthesisB2 = print(')')
else:
    ParenthesisA2 = print(' ')
    ParenthesisB2 = print(' ')
print(ParenthesisA1, Random_Number1, Random_Power1, Random_Sign1, Random_Number2, ParenthesisB1, Random_Power2, Random_Sign2, ParenthesisA2, Random_Number3, Random_Power3, Random_Sign3, Random_Number4, ParenthesisB2, Random_Power4, Random_Sign4, Random_Number5, Random_Power5,)
answer = 
input = answer_input
if answer_input == answer:
    print(' ')
    print('Nice Work! You Really Know Your Stuff.')
else:
    print(' ')
    print('Sorry... That is Incorrect')
Output:
A random expression will be created that you must solve. *IMPORTANT: SR-Square Root, P2-Squared, P3-Cubed, SR2-Square root of, etc. ( ) ( ) None 64 SR3 * 23 None P5 - None 63 SR1 / 57 None SR5 * 1 P5 Nice Work! You Really Know Your Stuff.
Reply


Messages In This Thread
Random Expression Creator - by SheeppOSU - Nov-01-2018, 10:37 PM
RE: Random Expression Creator - by j.crater - Nov-01-2018, 11:05 PM
RE: Random Expression Creator - by wavic - Nov-01-2018, 11:08 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Wanted to tag azure resources with creator name raham3406 0 1,517 Apr-25-2021, 02:24 PM
Last Post: raham3406
  Pass results of expression to another expression cmdr_eggplant 2 2,423 Mar-26-2020, 06:59 AM
Last Post: ndc85430
  List creator acmichelman 4 4,333 Sep-04-2017, 09:12 PM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020