Geoarge_Whright
Badges: 4
Rep:
?
#1
Report Thread starter 1 month ago
#1
Ok so far I've done this

# ------------------------------------------------------------
# Global variables
# ------------------------------------------------------------
count = 1
number = 1

# ------------------------------------------------------------
# Main program
# ------------------------------------------------------------
number = int (input ("Enter a number 1 to 12: "))

# =====> Complete the brackets
if ( number<1):
print ("Number is too small")
# =====> Complete the brackets
elif (number > 1):
print ("Number is too large")
else:
# =====> Complete the brackets
while ( ):
print (str(number) + " x " + str(count) + " = " + str(count * number))
# =====> Add a line to keep the loop going around


Any help would be sooooo appreciated!!!

I've attached the question : )
Attached files
Last edited by Geoarge_Whright; 1 month ago
0
reply
Upthefilm
Badges: 7
Rep:
?
#2
Report 1 month ago
#2
(Original post by Geoarge_Whright)
Ok so far I've done this

# ------------------------------------------------------------
# Global variables
# ------------------------------------------------------------
count = 1
number = 1

# ------------------------------------------------------------
# Main program
# ------------------------------------------------------------
number = int (input ("Enter a number 1 to 12: "))

# =====> Complete the brackets
if ( number<1):
print ("Number is too small")
# =====> Complete the brackets
elif (number > 1):
print ("Number is too large")
else:
# =====> Complete the brackets
while ( ):
print (str(number) + " x " + str(count) + " = " + str(count * number))
# =====> Add a line to keep the loop going around


Any help would be sooooo appreciated!!!

I've attached the question : )
Which part are you struggling with here?
0
reply
Geoarge_Whright
Badges: 4
Rep:
?
#3
Report Thread starter 1 month ago
#3
(Original post by Upthefilm)
Which part are you struggling with here?
Hi!

uhm the process of the question tbh

Is this part right?

if ( number<1):
print ("Number is too small")
# =====> Complete the brackets
elif (number > 1):
print ("Number is too large")
else:
0
reply
Upthefilm
Badges: 7
Rep:
?
#4
Report 1 month ago
#4
(Original post by Geoarge_Whright)
Hi!

uhm the process of the question tbh

Is this part right?

if ( number<1):
print ("Number is too small")
# =====> Complete the brackets
elif (number > 1):
print ("Number is too large")
else:
First statement seems fine. For your second if statement , you are saying that any number greater than 1 is too large to enter, refer back to the question to see what range of numbers can be entered.
1
reply
username5770391
Badges: 14
Rep:
?
#5
Report 1 month ago
#5
(Original post by Geoarge_Whright)
Ok so far I've done this

# ------------------------------------------------------------
# Global variables
# ------------------------------------------------------------
count = 1
number = 1

# ------------------------------------------------------------
# Main program
# ------------------------------------------------------------
number = int (input ("Enter a number 1 to 12: "))

# =====> Complete the brackets
if ( number<1):
print ("Number is too small")
# =====> Complete the brackets
elif (number > 1):
print ("Number is too large")
else:
# =====> Complete the brackets
while ( ):
print (str(number) + " x " + str(count) + " = " + str(count * number))
# =====> Add a line to keep the loop going around


Any help would be sooooo appreciated!!!

I've attached the question : )
Good start, and you're partially right.

First bracket (number < 1) is correct. Any number below 1 is too small.

For the second bracket you've put (number > 1). That's not correct. If you entered 2, the program would tell you that's too large

Have you got any thoughts on the third bracket (the while loop) and the line you need to add to keep the loop going? These two are related, so you might not get the line to add until you've got the while loop
1
reply
Geoarge_Whright
Badges: 4
Rep:
?
#6
Report Thread starter 1 month ago
#6
(Original post by Acsel)
Good start, and you're partially right.

First bracket (number < 1) is correct. Any number below 1 is too small.

For the second bracket you've put (number > 1). That's not correct. If you entered 2, the program would tell you that's too large

Have you got any thoughts on the third bracket (the while loop) and the line you need to add to keep the loop going? These two are related, so you might not get the line to add until you've got the while loop
Ah yes I see now. the second bracket should be number>12

Not too sure on the while loop though
0
reply
Geoarge_Whright
Badges: 4
Rep:
?
#7
Report Thread starter 1 month ago
#7
(Original post by Upthefilm)
First statement seems fine. For your second if statement , you are saying that any number greater than 1 is too large to enter, refer back to the question to see what range of numbers can be entered.
Ah yes I see now. the second bracket should be number>12



Not too sure on the while loop though
0
reply
Geoarge_Whright
Badges: 4
Rep:
?
#8
Report Thread starter 1 month ago
#8
(Original post by Upthefilm)
First statement seems fine. For your second if statement , you are saying that any number greater than 1 is too large to enter, refer back to the question to see what range of numbers can be entered.
Is the while part number?
0
reply
Upthefilm
Badges: 7
Rep:
?
#9
Report 1 month ago
#9
(Original post by Geoarge_Whright)
Ah yes I see now. the second bracket should be number>12



Not too sure on the while loop though
No worries,
Now Inside those brackets they are looking for a condition to placed in them so that the print statement will run a certain amount of times (look at the example they give). They have given a variable for you to use, you must think about how many times do I want this print statement to run and how can i ensure that it won't run more than necessary by using this variable.

The line they require you too write is so that the condition you make in the while loop can be met, in this case it will be updating a variable.

not sure how much help this was so let me know if you require anymore help
0
reply
username5770391
Badges: 14
Rep:
?
#10
Report 1 month ago
#10
(Original post by Geoarge_Whright)
Ah yes I see now. the second bracket should be number>12



Not too sure on the while loop though
Correct.

For the while loop, see what Upthefilm wrote above
0
reply
X

Quick Reply

Attached files
Write a reply...
Reply
new posts
Back
to top
Latest
My Feed

See more of what you like on
The Student Room

You can personalise what you see on TSR. Tell us a little about yourself to get started.

Personalise

Are you tempted to change your firm university choice on A-level results day?

Yes, I'll try and go to a uni higher up the league tables (42)
27.1%
Yes, there is a uni that I prefer and I'll fit in better (14)
9.03%
No I am happy with my choice (88)
56.77%
I'm using Clearing when I have my exam results (11)
7.1%

Watched Threads

View All