Welcome, Guest: Join Nairaland / LOGIN! / Trending / Recent / New
Stats: 2,862,986 members, 6,869,026 topics. Date: Wednesday, 18 May 2022 at 03:25 PM

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 (1277 Views)

Ogun State Traims 200 Trained In Python Programming Language / Python 3: Exercises And Solutions. / 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)

A Place To Learn And Develop Software Applications In 10 Weeks / Urgently Need A Php Developer / What Is Node.js And What Can It Do, Why Should I Learn

(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 - 2022 Oluwaseun Osewa. All rights reserved. See How To Advertise. 46
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.