Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,150,080 members, 7,807,229 topics. Date: Wednesday, 24 April 2024 at 11:22 AM

How To Write A Guessing Game Program In Python 3 - Programming - Nairaland

Nairaland Forum / Science/Technology / Programming / How To Write A Guessing Game Program In Python 3 (1407 Views)

Python 3: Exercises And Solutions. / Salesforce Rest API Example Using Python 3 / Consume Kibana Rest API Using Python 3 (2) (3) (4)

(1) (Reply) (Go Down)

How To Write A Guessing Game Program In Python 3 by michelle5683(f): 3:59pm On Sep 23, 2017
while true
import random
comguess= random.randint(0,100)
user guess = int(input("Guess a number between 1 - 100: "wink)
if userguess > comguess:
print ("Guess lower"wink
elif userguess < comguess:
print ("Guess higher"wink
else:
print ("you are correct! "wink
break

Forgive my indentation, I typed this with an Android device.

Enjoy
Re: How To Write A Guessing Game Program In Python 3 by michelle5683(f): 4:04pm On Sep 23, 2017
Wherever you see a wink it's actually a column and bracket. I don't know how to modify posts.
Re: How To Write A Guessing Game Program In Python 3 by 4kings: 4:06pm On Sep 23, 2017
Cool, next time put you code within the code tag to avoid indentation problems.
Can you work with exception handling or isinstance function to handle incorrect user input?

And since you had your 9hours tutorial video, can you provide a gui implementation of this?
Re: How To Write A Guessing Game Program In Python 3 by michelle5683(f): 4:08pm On Sep 23, 2017
4kings:
Cool, next time put you code within the code tag to avoid indentation problems.
Can you work with exception handling or isinstance function to handle incorrect user input?

And since you had your 9hours tutorial video, can you provide a gui implementation of this?
Perhaps if you explanced the instance I'd know if I've learnt it and perhaps haven't taken not of the name.

The video didn't teach me GUI.
Re: How To Write A Guessing Game Program In Python 3 by 4kings: 4:17pm On Sep 23, 2017
michelle5683:

Perhaps if you explanced the instance I'd know if I've learnt it and perhaps haven't taken not of the name.

The video didn't teach me GUI.
var = input('Enter number: ')
isinstance(var, int)
This returns true if var is an integer.

So it can be tweaked to:

if isinstance(var, int) == False:
print('Value entered is not a number \n please enter a valid number')
var = input('Enter number: ')


You can learn GUI here: https://pythonprogramming.net/gui-development-tutorials/
Re: How To Write A Guessing Game Program In Python 3 by michelle5683(f): 4:37pm On Sep 23, 2017
4kings:

var = input('Enter number: ')
isinstance(var, int)
This returns true if var is an integer.

So it can be tweaked to:

if isinstance(var, int) == False:
print('Value entered is not a number \n please enter a valid number')
var = input('Enter number: ')


You can learn GUI here: https://pythonprogramming.net/gui-development-tutorials/

Wow thanks a million

1 Like

Re: How To Write A Guessing Game Program In Python 3 by michelle5683(f): 5:20pm On Sep 23, 2017
4kings:

var = input('Enter number: ')
isinstance(var, int)
This returns true if var is an integer.

So it can be tweaked to:

if isinstance(var, int) == False:
print('Value entered is not a number \n please enter a valid number')
var = input('Enter number: ')


You can learn GUI here: https://pythonprogramming.net/gui-development-tutorials/

I'm at the site now and I've commenced learning. What module is best for GUI
Re: How To Write A Guessing Game Program In Python 3 by 4kings: 5:31pm On Sep 23, 2017
michelle5683:


I'm at the site now and I've commenced learning. What module is best for GUI
Kivy is the best, since it's cross platform(can be used on android, ios, etc).
Re: How To Write A Guessing Game Program In Python 3 by michelle5683(f): 5:32pm On Sep 23, 2017
4kings:

Kivy is the best, since it's cross platform(can be used on android, ios, etc).

Thank you a lot
Re: How To Write A Guessing Game Program In Python 3 by Exoticstan(m): 8:47pm On Sep 23, 2017
4kings:

Kivy is the best, since it's cross platform(can be used on android, ios, etc).
Bro, I believe in you're an expert on Python programming. U need to ask you a private question or two by call perhaps. Contact?
Re: How To Write A Guessing Game Program In Python 3 by 4kings: 1:12am On Sep 24, 2017
Exoticstan:
Bro, I believe in you're an expert on Python programming. U need to ask you a private question or two by call perhaps. Contact?
Mail is preferable. Just send me an email.
By the way, i'm no expert.
Re: How To Write A Guessing Game Program In Python 3 by crunchyDope(m): 10:10am On Sep 25, 2017
michelle5683:
your indention


put ur codes inside this ==> [pre] #ur codes [/pre ]

*note , no space after "pre"

(1) (Reply)

I Need A Webmaster Who Can Create A Professional Website With Cpanel Emails. / I'm Hiring Great Developers, Come Learn From A Master / I Need Your Advise/help

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 17
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.