codenewbie202
Posts: 1
Joined: Fri Apr 17, 2020 9:02 pm

Coding: What will the output of the following lines of code:

Fri Apr 17, 2020 9:34 pm

What will be the output of the following lines of code:

Code: Select all

guess = 0

if guess >= 1:

    x = input("pick a number")

else:

    try = input("would you like to play again")

    if try =="y":

        guess = 3

    else:

        guess = 0

User avatar
B.Goode
Posts: 10356
Joined: Mon Sep 01, 2014 4:03 pm
Location: UK

Re: Coding: What will the output of the following lines of code:

Sat Apr 18, 2020 2:32 pm

codenewbie202 wrote:
Fri Apr 17, 2020 9:34 pm
What will be the output of the following lines of code:

Code: Select all

guess = 0

if guess >= 1:

    x = input("pick a number")

else:

    try = input("would you like to play again")

    if try =="y":

        guess = 3

    else:

        guess = 0


Possibly:
would you like to play again



(But I'm puzzled as to why it is necessary to ask....These are the Raspberry Pi forums, so if you have a Raspberry Pi system it would have been far quicker to have run the code to find out for yourself.... )

hippy
Posts: 7908
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: Coding: What will the output of the following lines of code:

Sat Apr 18, 2020 5:32 pm

codenewbie202 wrote:
Fri Apr 17, 2020 9:34 pm
What will be the output of the following lines of code:
I wouldn't have expected any output, only a syntax error where you have -

try = input("would you like to play again")

That 'try' is a reserved word, cannot be used as a variable.

User avatar
B.Goode
Posts: 10356
Joined: Mon Sep 01, 2014 4:03 pm
Location: UK

Re: Coding: What will the output of the following lines of code:

Sat Apr 18, 2020 5:35 pm

hippy wrote:
Sat Apr 18, 2020 5:32 pm
codenewbie202 wrote:
Fri Apr 17, 2020 9:34 pm
What will be the output of the following lines of code:
I wouldn't have expected any output, only a syntax error where you have -

try = input("would you like to play again")

That 'try' is a reserved word, cannot be used as a variable.

Missed that - thanks.

Return to “Python”