Python Forum
Newbie to Python, Need help with how to impliment random values
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Newbie to Python, Need help with how to impliment random values
#1
Hello everyone, I just started doing Python after I learned a little bit of the language in Computer Science class. (A program at my school.) I am making an RPG and just wondering how I implement random values. For example, the player does between 3-5 damage to enemy, and when the system chooses a value, it subtracts from the monster's HP. Thanks alot for helping.  Smile
Reply
#2
Use the random module
Reply
#3
(Dec-19-2016, 12:49 AM)Yoriz Wrote: Use the random module

Okay, but what about number ranges? (3-5, 1-2, etc.)
Reply
#4
Yes
Reply
#5
(Dec-19-2016, 12:53 AM)Yoriz Wrote: Yes

Oh wait I saw. Now how do I make that random value subtract from a variable?
Reply
#6
variable - random_value
Reply
#7
(Dec-19-2016, 01:08 AM)Yoriz Wrote:
variable - random_value

Wow! Thanks again!  Smile
Now if you don't mind me asking one more... how do you use greater than or less than to compare variables and values? (if variable > 0)
Reply
#8
Suggest you take a basic python tutorial
Reply
#9
Yes that is correct
if variable > 0:
    print('Greater than 0')
if variable < 10:
    print('Less than 10')
if 10 > variable > 0:
    print('Its between')
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Python newbie laleebee 2 1,286 May-24-2022, 01:39 PM
Last Post: laleebee
  Newbie on Python syntax rud0lp20 6 2,877 Apr-21-2020, 04:26 PM
Last Post: jefsummers
  python newbie marcush929 2 2,561 Jan-01-2020, 08:06 AM
Last Post: marcush929
Smile Help needed. Python Newbie!, it will be fun. knightdea 3 2,579 Oct-13-2019, 08:50 AM
Last Post: perfringo
  Python Linting (newbie) LieveHeer 2 2,579 Jan-24-2019, 05:36 PM
Last Post: LieveHeer
  Python newbie is asking Marcus_Gondwe 4 3,377 Apr-04-2018, 11:08 AM
Last Post: Marcus_Gondwe
  Newbie ? Python 3 Input() jlgrunr 1 2,429 Feb-17-2018, 10:26 PM
Last Post: Gribouillis
  Python Newbie phylon 1 26,950 Jan-09-2018, 10:46 AM
Last Post: Gribouillis
  Newbie question: random Truman 8 4,838 Dec-19-2017, 09:27 PM
Last Post: Truman
  NEWBIE HELP: How to tell Python when to use a function BoaVenom18 4 5,349 Dec-17-2016, 09:00 PM
Last Post: j.crater

Forum Jump:

User Panel Messages

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