Technology Get the latest on technology, electronics and software…

Computer experts needed! Python programing?

Thread Tools
 
Old Aug 13, 2010 | 10:08 PM
  #1  
msmching's Avatar
Thread Starter
Ex-King of Pasadena
 
Joined: Feb 2007
Posts: 1,033
Likes: 0
From: CA, 91107
Computer experts needed! Python programing?

Hi guys. Need a little help with this.

I m trying to write out a very simple game by using python script.

______________________________________________
Mac people: go to http://www.python.org/download/mac/ for some basic information, and to http://www.python.org/download/releases/á to download it.

Windows People: you can go to http://www.portablepython.com/ for basic information about Portable Python.á Go to http://www.portablepython.com/wiki/P...thon1.1Py3.0.1 to download it.á I would recommend the http link for USA.á You will download one .exe file, which you should put on a flash drive.á When you run it, it won't install anything, but create a folder with two .exe files and another file in it.á That's it! You don't have to do anything else.
______________________________________________
Information above is where i got the python from. (which is what the professor gave it to us.).

This thing is just totally new to me, but the professor teaches us as if we have knowledge about it. lol. It's a GE requirement class for me, Computer Science. (I'm a business major).

Anyway, if anyone knows about it, here's what i have now.

________________________
import random
guesses = 0
ran = random.randint (1,50)

yourname = input('what is your name?:')
print('hi')
print('well, i am thinking of a number between 1 and 20')
print('you have 10 guesses to figure it out')

while guesses <10:
yourguest = int(input('what is your guess?'))
if yourguest == ran:
print('you are right, congratulation !!!')
break;
elif yourguest > ran:
print('your guess is too high')
elif yourguest < ran:
print('your guess is too low')
guesses = guesses + 1
print('you are wrong, please try again!')
print('you have ' + str(10-guesses) + ' left')

if guesses ==6:
print('you lost!!!')
print ('done')
_________________________

It's a small guessing game. I just want to add something on it, but i can't seem to come up with the right thing. !!


Two things i want to add on it.

- After typing in the name when the game prompts to, instead of saying just HI, i want it to say ( HI "the name entered".. )
- Also, I want to end the game and then have a line to ask " Do you want to try again? YES OR NO.
If Yes, the whole thing go over again, while if No is entered, it ends the game with THANKS FOR PLAYING.

Ideas?? Thankss!!
Reply
Old Aug 13, 2010 | 11:25 PM
  #2  
mdkxtreme's Avatar
Moderator
 
Joined: Oct 2007
Posts: 3,578
Likes: 322
From: Orange County, CA
I think you should be good with this. Don't know why it doesn't show the indent in here. Added pic for you. Good luck with the class. CS was hard when I first started too

================================================== ==============

import random
guesses = 0
ran = random.randint (1,20)
cond = True

yourname = input('What is your name?:')
print('Hi' + ' ' + yourname)
print('Well, I am thinking of a number between 1 and 20.')
print('You have 10 guesses to figure it out.')

while cond == True:
while guesses < 10:
yourguest = int(input('What is your guess?'))
if yourguest == ran:
print('You are right. Congratulations!!!')
cond = False
break
elif yourguest > ran:
print('Your guess is too high!')
elif yourguest < ran:
print('Your guess is too low! Please try again!')
guesses = guesses + 1
print('You have ' + str(10-guesses) + ' left.')
if guesses == 10:
print('You lost!!!')
tryAgain = input('Would you like to try again?')
if tryAgain == "no":
print('Thanks for playing!!!')
cond = False
if tryAgain == "No":
print('Thanks for playing!!!')
cond = False
guesses = 0


Last edited by mdkxtreme; Aug 13, 2010 at 11:33 PM.
Reply
Old Aug 13, 2010 | 11:31 PM
  #3  
TS_eXpeed's Avatar
Team Owner
 
Joined: Jun 2007
Posts: 23,451
Likes: 54
Reply
Old Aug 14, 2010 | 12:31 AM
  #4  
Gfaze's Avatar
S E L L
15 Year Member
Liked
Loved
Community Favorite
 
Joined: May 2007
Posts: 12,768
Likes: 51
From: Modesto, CA
Originally Posted by TS_eXpeed
I hate programming. No patience for it.
Reply
Old Aug 14, 2010 | 07:23 AM
  #5  
Anachostic's Avatar
Safety Car
 
Joined: Jul 2007
Posts: 4,845
Likes: 145
Use the code tag:
Code:
import random
guesses = 0
ran = random.randint (1,20)
cond = True

yourname = input('What is your name?:')
print('Hi' +  ' ' + yourname)
print('Well, I am thinking of a number between 1 and 20.')
print('You have 10 guesses to figure it out.')

while cond == True:
    while guesses < 10:
        yourguest = int(input('What is your guess?'))
        if yourguest == ran:
            print('You are right. Congratulations!!!')
            cond = False
            break
        elif yourguest > ran:
            print('Your guess is too high!')
        elif yourguest < ran:
            print('Your guess is too low! Please try again!')
        guesses = guesses + 1
        print('You have ' + str(10-guesses) + ' left.')
    if guesses == 10:
        print('You lost!!!')
        tryAgain = input('Would you like to try again?')
        if tryAgain == "no":
            print('Thanks for playing!!!')
            cond = False
        if tryAgain == "No":
            print('Thanks for playing!!!')
            cond = False
        guesses = 0
Reply
Old Aug 14, 2010 | 08:20 AM
  #6  
Whiskers's Avatar
Go Giants
20 Year Member
Liked
Loved
Community Favorite
 
Joined: Aug 2004
Posts: 70,003
Likes: 1,260
From: PA
Um.yeah.
Reply
Old Aug 14, 2010 | 12:36 PM
  #7  
msmching's Avatar
Thread Starter
Ex-King of Pasadena
 
Joined: Feb 2007
Posts: 1,033
Likes: 0
From: CA, 91107
Originally Posted by Anachostic
Use the code tag:
Code:
import random
guesses = 0
ran = random.randint (1,20)
cond = True

yourname = input('What is your name?:')
print('Hi' +  ' ' + yourname)
print('Well, I am thinking of a number between 1 and 20.')
print('You have 10 guesses to figure it out.')

while cond == True:
    while guesses < 10:
        yourguest = int(input('What is your guess?'))
        if yourguest == ran:
            print('You are right. Congratulations!!!')
            cond = False
            break
        elif yourguest > ran:
            print('Your guess is too high!')
        elif yourguest < ran:
            print('Your guess is too low! Please try again!')
        guesses = guesses + 1
        print('You have ' + str(10-guesses) + ' left.')
    if guesses == 10:
        print('You lost!!!')
        tryAgain = input('Would you like to try again?')
        if tryAgain == "no":
            print('Thanks for playing!!!')
            cond = False
        if tryAgain == "No":
            print('Thanks for playing!!!')
            cond = False
        guesses = 0
Thanks for making it easier.. haha..

Originally Posted by mdkxtreme
I think you should be good with this. Don't know why it doesn't show the indent in here. Added pic for you. Good luck with the class. CS was hard when I first started too

================================================== ==============

import random
guesses = 0
ran = random.randint (1,20)
cond = True

yourname = input('What is your name?:')
print('Hi' + ' ' + yourname)
print('Well, I am thinking of a number between 1 and 20.')
print('You have 10 guesses to figure it out.')

while cond == True:
while guesses < 10:
yourguest = int(input('What is your guess?'))
if yourguest == ran:
print('You are right. Congratulations!!!')
cond = False
break
elif yourguest > ran:
print('Your guess is too high!')
elif yourguest < ran:
print('Your guess is too low! Please try again!')
guesses = guesses + 1
print('You have ' + str(10-guesses) + ' left.')
if guesses == 10:
print('You lost!!!')
tryAgain = input('Would you like to try again?')
if tryAgain == "no":
print('Thanks for playing!!!')
cond = False
if tryAgain == "No":
print('Thanks for playing!!!')
cond = False
guesses = 0

I didn't know you know these stuff!!! Instead of hanging around for hours, I should have just call you first lol
Reply
Old Aug 16, 2010 | 11:10 AM
  #8  
Scottman111's Avatar
1919
 
Joined: Mar 2005
Posts: 21,467
Likes: 162
If/when you get to Java you're gonna kill yourself
Reply
Old Jul 1, 2014 | 08:14 PM
  #9  
stogie1020's Avatar
Needs more Lemon Pledge
 
Joined: Mar 2005
Posts: 52,768
Likes: 2,000
From: Phoenix, AZ
So, I want to learn python. any good recommendations for learning?
Reply
Old Jul 1, 2014 | 09:23 PM
  #10  
mdkxtreme's Avatar
Moderator
 
Joined: Oct 2007
Posts: 3,578
Likes: 322
From: Orange County, CA
There's a lot of interactive code courses online. But this was the one that I used to learn Javascript and a bit of Python: http://www.codecademy.com/en/tracks/python
Reply
Old Jul 2, 2014 | 08:37 AM
  #11  
doopstr's Avatar
Team Owner
20 Year Member
Liked
Loved
Community Favorite
 
Joined: Jan 2001
Posts: 25,967
Likes: 2,685
From: Jersey
hashtag?
Reply
Old Jul 2, 2014 | 08:38 AM
  #12  
doopstr's Avatar
Team Owner
20 Year Member
Liked
Loved
Community Favorite
 
Joined: Jan 2001
Posts: 25,967
Likes: 2,685
From: Jersey
Originally Posted by stogie1020
So, I want to learn python. any good recommendations for learning?
http://learnpythonthehardway.org/book/
Reply
Old Jul 2, 2014 | 11:18 AM
  #13  
stogie1020's Avatar
Needs more Lemon Pledge
 
Joined: Mar 2005
Posts: 52,768
Likes: 2,000
From: Phoenix, AZ
Thanks guys.

Downloaded python 3.4.1 and IDLE, been playing with it a bit

The last programming I did was loops in Basic to make my name scroll on the screen....

Last edited by stogie1020; Jul 2, 2014 at 11:21 AM.
Reply
Old Jul 15, 2014 | 08:54 AM
  #14  
Scottman111's Avatar
1919
 
Joined: Mar 2005
Posts: 21,467
Likes: 162
Any reason you want to learn Python over something like Java?

I had to take both in college...learning Python first was supposed to make learning Java easier, but in the end it confused the hell out of us.

/still hate programming
Reply
Old Jul 15, 2014 | 11:33 AM
  #15  
stogie1020's Avatar
Needs more Lemon Pledge
 
Joined: Mar 2005
Posts: 52,768
Likes: 2,000
From: Phoenix, AZ
Some colleagues were discussing using it to accomplish some tasks that they were working on and there is a small community of people developing python scripts for certain relevant purposes to my work.
Reply
Old Jul 15, 2014 | 12:08 PM
  #16  
Scottman111's Avatar
1919
 
Joined: Mar 2005
Posts: 21,467
Likes: 162
Interesting. Ever worked with Ruby?

I can probably send you my programming stuff from school if you'd like...books/tutorials/software from class and anything else leftover. I have most of it saved somewhere that I'll never use again.
Reply
Old Jul 15, 2014 | 06:16 PM
  #17  
mdkxtreme's Avatar
Moderator
 
Joined: Oct 2007
Posts: 3,578
Likes: 322
From: Orange County, CA
Originally Posted by Scottman111
Any reason you want to learn Python over something like Java?

I had to take both in college...learning Python first was supposed to make learning Java easier, but in the end it confused the hell out of us.

/still hate programming
Interestingly, my university recently switched from Java to Python as their programming language choice for the Introduction to Computer Programming course. They figured Java was too confusing for people trying to dive into programming. I think it's a good decision because once you have just the core logic down (loops, conditions, data structures), everything else is just syntax.
Reply
Old Jul 21, 2014 | 02:19 PM
  #18  
Legend2TL's Avatar
AZ Community Team
20 Year Member
Liked
Loved
Community Favorite
 
Joined: Nov 2004
Posts: 19,092
Likes: 4,758
From: Maryland
Originally Posted by stogie1020
So, I want to learn python. any good recommendations for learning?
codeacademy.org

Great free online way to learn Python, PHP, Javascript, Ruby,...

I highly recommend it
Reply
Related Topics
Thread
Thread Starter
Forum
Replies
Last Post
rockyboy
2G RDX (2013-2018)
171
Aug 4, 2024 10:35 AM
notfast
1/2G MDX (2001-2013)
9
Mar 28, 2023 08:10 AM
Yumcha
Automotive News
9
Feb 25, 2020 09:57 AM
BKSleeper
3G TL Problems & Fixes
21
Oct 7, 2015 10:20 AM
Rocktman1
5G TLX Audio, Bluetooth, Electronics & Navigation
4
Sep 19, 2015 05:58 PM




All times are GMT -5. The time now is 05:42 AM.