•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the Python section within the Software Development category of DaniWeb, a massive community of 391,596 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,706 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Python advertiser:
Views: 53389 | Replies: 158
![]() |
python Syntax (Toggle Plain Text)
# This is text from a file I found. Write a Python program to # convert the text into a dictionary with "state": "motto" pairs # something like {"Alabama": "At Least We're not Mississippi", # "Alaska": "11,623 Eskimos Can't be Wrong!", ...} # # Then write a program that allows you to enter the state and # it will display the motto of that state. state_mottos = """\ Alabama: At Least We're not Mississippi Alaska: 11,623 Eskimos Can't be Wrong! Arizona But It's a Dry Heat Arkansas: Litterasy Ain't Everthing California: As Seen on TV Colorado: If You Don't Ski, Don't Bother Connecticut: Like Massachusetts, Only Dirtier and with less Character Delaware: We Really Do Like the Chemicals in our Water Florida: Ask Us About Our Grandkids Georgia: We Put the 'Fun' in Fundamentalist Extremism Hawaii: Haka Tiki Mou Sha'ami Leeki Toru (Death to Mainland Scum, But Leave Your Money) Idaho: More Than Just Potatoes... Well Okay, Maybe Not, But The Potatoes Sure Are Good Illinois: Please Don't Pronounce the "S" Indiana: 2 Billion Years Tidal Wave Free Iowa: We Do Amazing Things With Corn Kansas: First Of The Rectangle States Kentucky: Five Million People; Fifteen Last Names Louisiana: We're Not All Drunk Cajun Wackos, But That's Our Tourism Campaign Maine: We're Really Cold, But We Have Cheap Lobster Maryland: A Thinking Man's Delaware Massachusetts: Our Taxes Are Lower Than Sweden's (For Most Tax Brackets) Michigan: First Line of Defense From the Canadians Minnesota: 10,000 Lakes and 10,000,000 Mosquitoes Mississippi: Come Feel Better About Your Own State Missouri: Your Federal Flood Relief Tax Dollars at Work Montana: Land of the Big Sky, the Unabomber, Right-Wing Crazies, and Very Little Else Nebraska: Ask About Our State Motto Contest Nevada: Whores and Poker! New Hampshire: Go Away and Leave Us Alone New Jersey: You Want a ##$%##! Motto? I Got Yer ##$%##! Motto Right Here! New Mexico: Lizards Make Excellent Pets New York: You Have the Right to Remain Silent, You Have the Right to an Attorney... North Carolina: Tobacco is a Vegetable North Dakota: We Really are One of the 50 States! Ohio: We Wish We Were In Michigan Oklahoma: Like the Play, only No Singing Oregon: Spotted Owl... It's What's For Dinner Pennsylvania: Cook With Coal Rhode Island: We're Not REALLY An Island South Carolina: Remember the Civil War? We Didn't Actually Surrender South Dakota: Closer Than North Dakota Tennessee: The Educashun State Texas: Si' Hablo Ingles Utah: Our Jesus Is Better Than Your Jesus Vermont: Yep Virginia: Who Says Government Stiffs and Slackjaw Yokels Don't Mix? Washington: Help! We're Overrun By Nerds and Slackers! Washington, D.C.: Wanna Be Mayor? West Virginia: One Big Happy Family -- Really! Wisconsin: Come Cut Our Cheese Wyoming: Wynot? """
Last edited by Ene Uran : Aug 9th, 2007 at 5:15 pm. Reason: it will
drink her pretty
•
•
Join Date: Oct 2004
Location: Mojave Desert
Posts: 2,394
Reputation:
Rep Power: 9
Solved Threads: 172
Write an anagram program that takes someone's name and uses all the letters to create a phrase, for instance:
Osama Bin Laden --> 'bad neon salami'
George W Bush --> 'whose bugger'
George Bush --> 'he bugs Gore'
Tony Blair --> 'bony trail'
Ronald Reagan --> 'loan arranged'
David Letterman --> 'nerd amid late TV'
Elvis --> 'lives'
... beyond names:
The Morse Code --> Here Come Dots
Slot Machines --> Cash Lost in'em
Mother-in-law --> Woman Hitler
Statue of Liberty --> Built to Stay Free
New York Times --> Monkey writes
eleven plus two --> twelve plus one
You could also write a Python program that checks the above anagrams for correctness.
Osama Bin Laden --> 'bad neon salami'
George W Bush --> 'whose bugger'
George Bush --> 'he bugs Gore'
Tony Blair --> 'bony trail'
Ronald Reagan --> 'loan arranged'
David Letterman --> 'nerd amid late TV'
Elvis --> 'lives'
... beyond names:
The Morse Code --> Here Come Dots
Slot Machines --> Cash Lost in'em
Mother-in-law --> Woman Hitler
Statue of Liberty --> Built to Stay Free
New York Times --> Monkey writes
eleven plus two --> twelve plus one
You could also write a Python program that checks the above anagrams for correctness.
Last edited by vegaseat : Sep 4th, 2007 at 1:08 pm. Reason: more spelling
May 'the Google' be with you!
Something little more entertaining:
•
•
•
•
Write program that prints the numbers from 1 to 100. But for multiples of three print “Fizz” instead of the number, and for the multiples of five print “Buzz”. For numbers which are multiples of both three and five print “FizzBuzz”.
Last edited by bumsfeld : Sep 2nd, 2007 at 3:59 pm.
Should you find Irony, you can keep her!
•
•
Join Date: Feb 2007
Location: St. Vincent and the Grenadines, Caribbean
Posts: 947
Reputation:
Rep Power: 3
Solved Threads: 39
Topic: Encryption
#1 Write a program that that encrypts a string based on a alphanumeric key input by the user (or a number for a step encrypt program).
#2 enhance your program in #1 so that is the encrypted output is different every time, but can still be decrypted with the key.
#3 Modify the program in #2 so that it can handle private/public keys.
#4Write a script that can generate private and public keys for use with #3
#5 Write a program that can look for patterns in and break simple encryptions. Test it on #1, #2 and #3 (but do not write it based on your knowledge of howw they work). Be sure to set timouts, ie., if your loops exceed a certain amount of runs, force to program to stop, instead of hanging.
In the above:
Think of an innovative way to use dictionaries in any/all.
the random module will help in #2. But using it incorrectly will yield an undesired result. A bit of thinking and planning would be required. Perhaps there is way way to do this without random. Can you think of it?
char() and ord() functions in python are useful.
Comment your code, and use meaningful variable names. You will soon find that your program will swell at a rapid rate and otherwise understanding will be difficult. It is also a good practise to employ regardless what what you program
#1 Write a program that that encrypts a string based on a alphanumeric key input by the user (or a number for a step encrypt program).
#2 enhance your program in #1 so that is the encrypted output is different every time, but can still be decrypted with the key.
#3 Modify the program in #2 so that it can handle private/public keys.
#4Write a script that can generate private and public keys for use with #3
#5 Write a program that can look for patterns in and break simple encryptions. Test it on #1, #2 and #3 (but do not write it based on your knowledge of howw they work). Be sure to set timouts, ie., if your loops exceed a certain amount of runs, force to program to stop, instead of hanging.
In the above:
Think of an innovative way to use dictionaries in any/all.
the random module will help in #2. But using it incorrectly will yield an undesired result. A bit of thinking and planning would be required. Perhaps there is way way to do this without random. Can you think of it?
char() and ord() functions in python are useful.
Comment your code, and use meaningful variable names. You will soon find that your program will swell at a rapid rate and otherwise understanding will be difficult. It is also a good practise to employ regardless what what you program
Last edited by scru : Sep 5th, 2007 at 5:45 pm.
•
•
Join Date: Dec 2007
Posts: 6
Reputation:
Rep Power: 0
Solved Threads: 0
I am having a problem with the green highlighted
items that appear in your text
How do I get " what looks like a magnifying glass
followed by code" and "what looks like a magnifying glass followed by keywords"
I still don't understand how to put that in my code. How is it done? Do I have to have some special test tool?
items that appear in your text
How do I get " what looks like a magnifying glass
followed by code" and "what looks like a magnifying glass followed by keywords"
I still don't understand how to put that in my code. How is it done? Do I have to have some special test tool?
That is one of the more nauseating features added by DaniWeb. It brings up unwanted advertisement from certain words.
Editor's note ...
To get rid of the green IntelliText, follow this path:
User Control Panel
Edit Options
Miscellaneous Options
Disable IntelliTXT
Editor's note ...
To get rid of the green IntelliText, follow this path:
User Control Panel
Edit Options
Miscellaneous Options
Disable IntelliTXT
Last edited by vegaseat : Dec 27th, 2007 at 3:37 pm. Reason: intellitext
No one died when Clinton lied.
•
•
Join Date: Oct 2004
Location: Mojave Desert
Posts: 2,394
Reputation:
Rep Power: 9
Solved Threads: 172
•
•
Join Date: Oct 2004
Location: Mojave Desert
Posts: 2,394
Reputation:
Rep Power: 9
Solved Threads: 172
Make a small plug-in (extension) with Python that for example opens a (new) file in one of the following free programs:
* Blender (3D modeling)
* The Gimp (2D editing)
* Inkscape (vector editing)
* OpenOffice (office suite)
Some info links:
Blender:
http://www.blender.org/
http://jmsoler.free.fr/didacticiel/b...cript00_en.htm
The Gimp
http://www.gimp.org/
http://www.jamesh.id.au/software/pygimp/
Inkscape
http://www.inkscape.org
http://www.inkscape.org/screenshots/...n&version=0.42
OpenOffice
http://www.openoffice.org/index.html
http://wiki.services.openoffice.org/wiki/Python
http://udk.openoffice.org/python/python-bridge.html
* Blender (3D modeling)
* The Gimp (2D editing)
* Inkscape (vector editing)
* OpenOffice (office suite)
Some info links:
Blender:
http://www.blender.org/
http://jmsoler.free.fr/didacticiel/b...cript00_en.htm
The Gimp
http://www.gimp.org/
http://www.jamesh.id.au/software/pygimp/
Inkscape
http://www.inkscape.org
http://www.inkscape.org/screenshots/...n&version=0.42
OpenOffice
http://www.openoffice.org/index.html
http://wiki.services.openoffice.org/wiki/Python
http://udk.openoffice.org/python/python-bridge.html
Last edited by Begjinner : Jan 27th, 2008 at 6:25 am.
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb Python Marketplace
- Ideal project for a beginner? (Python)
- Hep finding C++ Projects (Python)
- Help finding C++ Projects (C++)
- New task from Projects for the beginner: (Python)
Other Threads in the Python Forum
- Previous Thread: A thread about threads
- Next Thread: Math problem with Pygame



Linear Mode