Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Apr 24, 2011, 01:52 PM   #1
sammysam52
macrumors newbie
 
Join Date: Apr 2011
Palindrome program using Python Programming

I am having to write a program that determines whether a number is a palindrome or not using Python Programming. The program uses an input function for the number and then returns the results. All the research I have done has turned out results with Java and other non Python programs. Any help is appreciated. Thank you
sammysam52 is offline   0 Reply With Quote
Old Apr 24, 2011, 01:59 PM   #2
balamw
Moderator
 
balamw's Avatar
 
Join Date: Aug 2005
Location: New England, USA
Read http://whathaveyoutried.com and http://mikeash.com/getting_answers.html .

You are unlikely to get the answers you seek without giving us a lot more than you already have. Post any code you have tried that doesn't work. Post links to the Java code that you think does what you want, etc...

Especially if this sounds like homework, you need to at least try to solve it.

B
__________________
MBA (13" 1.7 GHz 128GB), UMBP (15" SD 2.8 GHz), UMB (13" 2.4 GHz), iMac (17" Yonah), 32GB iPad 3 WiFi+LTE, 64 GB iPad WiFi, 32 GB iPhone 5, Airport Extreme
balamw is offline   0 Reply With Quote
Old Apr 24, 2011, 02:03 PM   #3
chown33
macrumors 603
 
Join Date: Aug 2009
Did you try googling the obvious: palindrome python program

One of the top 10 hits is this:
http://forums.macrumors.com/showthread.php?t=861800
chown33 is offline   0 Reply With Quote
Old Apr 24, 2011, 02:13 PM   #4
balamw
Moderator
 
balamw's Avatar
 
Join Date: Aug 2005
Location: New England, USA
Quote:
Originally Posted by chown33 View Post
Did you try googling the obvious: palindrome python program

One of the top 10 hits is this:
http://forums.macrumors.com/showthread.php?t=861800
For sammysam52, the OP in that thread posted code and solved their own problem with a gentle nudge.

What is your approach?

B
__________________
MBA (13" 1.7 GHz 128GB), UMBP (15" SD 2.8 GHz), UMB (13" 2.4 GHz), iMac (17" Yonah), 32GB iPad 3 WiFi+LTE, 64 GB iPad WiFi, 32 GB iPhone 5, Airport Extreme
balamw is offline   0 Reply With Quote
Old Apr 24, 2011, 03:41 PM   #5
lee1210
macrumors 68040
 
lee1210's Avatar
 
Join Date: Jan 2005
Location: Dallas, TX
I don't really know why research is needed for this, unless you don't know Python at all. If that is the case, you don't need to research how to do this in Python, you just need to research Python. Finding code online that does what you need is easy. However, i doubt somewhat seriously that you have a real-world problem requiring this, and you're simply desperate for a solution. Instead this sounds like an academic assignment/exercise/what-have-you.

If that is the case, then you want to learn something, not find the answer. That means you might need to learn:
What a palindrome is (you probably already know this)

How to write a loop in Python

How to manipulate numbers using Python (including exponentiation and division, perhaps taking logarithms)
OR
How to manipulate strings using Python (including getting a substring, string equality, or character equality and getting characters)

As an academic exercise i would try to write both approaches... treating the number as a number and approaching this with math and treating the number with a string and dealing with it that way.

I'm confident that you can google your way to what a palindrome is if you don't know, and the Python documentation is actually quite good:
http://www.python.org/doc/

Good luck. As you progress feel free to post code here telling us what you've tried, what the current errors are (or erroneous results), what you expect to happen, etc. We'll be glad to help you work it out, but it's better for everyone if we don't give you the answer.

-Lee
lee1210 is offline   0 Reply With Quote
Old Apr 24, 2011, 05:10 PM   #6
KnightWRX
macrumors Pentium
 
KnightWRX's Avatar
 
Join Date: Jan 2009
Location: Quebec, Canada
Quote:
Originally Posted by chown33 View Post
Did you try googling the obvious: palindrome python program

One of the top 10 hits is this:
http://forums.macrumors.com/showthread.php?t=861800
Quote:
Originally Posted by lee1210 View Post
nstead this sounds like an academic assignment/exercise/what-have-you.
A quick suggestion OP : If this is homework, do not try "googling the obvious" and especially do not copy/paste code from the top 10 hits. If it was that easy to find, your teacher already found it also and will fail you with good reason when you try to turn in "Internet" code.
__________________
"What you leave behind is not what is engraved in stone monuments, but what is woven into the lives of others."
-- Pericles
KnightWRX is offline   0 Reply With Quote
Old Apr 24, 2011, 05:28 PM   #7
balamw
Moderator
 
balamw's Avatar
 
Join Date: Aug 2005
Location: New England, USA
Quote:
Originally Posted by lee1210 View Post
As an academic exercise i would try to write both approaches... treating the number as a number and approaching this with math and treating the number with a string and dealing with it that way.
That's one of the things that wasn't clear in the OP.

What is meant by "The program uses an input function for the number and then returns the results." is it supposed to be treated as a number or a string? Is the input part of the code specified in the problem statement?

Ultimately it doesn't matter since they both reduce to separating the number into digits/characters in either way.

B
__________________
MBA (13" 1.7 GHz 128GB), UMBP (15" SD 2.8 GHz), UMB (13" 2.4 GHz), iMac (17" Yonah), 32GB iPad 3 WiFi+LTE, 64 GB iPad WiFi, 32 GB iPhone 5, Airport Extreme
balamw is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
thread Thread Starter Forum Replies Last Post
how to use shimeji on mac using "wine" and "winebottler Ringo-Chan Windows, Linux & Others on the Mac 4 Apr 27, 2011 02:00 PM
Palindrome program using python tngisaga Mac Programming 4 Feb 8, 2010 09:27 PM
Python programing problem larswik Mac Programming 1 Feb 26, 2009 01:38 AM
One last python programming question iHerzeleid Mac Programming 6 Mar 15, 2008 12:44 AM
OSX email program using Microsoft Exchange Server smac411 General Mac Discussion 2 Mar 17, 2003 01:52 PM


All times are GMT -5. The time now is 10:11 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC