| | |
Python-Tuple Help!
Thread Solved |
•
•
Join Date: Dec 2008
Posts: 65
Reputation:
Solved Threads: 1
i have just been learning python(tuple) at school. And this is my first assignment. I can't seem to figure it out.
The assignment is on this website: http://schools.tdsb.on.ca/danforthcti/python/main.html
Go to lesson 8>scroll down>its called programming Assignment 9.
Can someone help me out? It's simple enough right? thank you!
The assignment is on this website: http://schools.tdsb.on.ca/danforthcti/python/main.html
Go to lesson 8>scroll down>its called programming Assignment 9.
Can someone help me out? It's simple enough right? thank you!
•
•
Join Date: Jan 2008
Posts: 3
Reputation:
Solved Threads: 2
Hi,
I think its very simple.
I will give you rough idea about it.
first, use raw_input() for asking user to enter number.
define tuple.
like
then use random library for random selection
got no time to write proper program but this will help you out. let me know if you want me to write program.
I think its very simple.
I will give you rough idea about it.
first, use raw_input() for asking user to enter number.
•
•
•
•
number =raw_input('How many item you need ?')
like
•
•
•
•
my_tuple = range(1,10)
•
•
•
•
import random
random.sample(my_tuple,number )
Last edited by rmansuri; Dec 2nd, 2008 at 5:29 am.
python Syntax (Toggle Plain Text)
mypocket = ("gum", "wallet", "old kleenex", "bus ticket") input_user = int (raw_input('How many item you need ? \n')) for i in range(input_user): print mypocket[i], #this will print from first to the limit of range #No catching of exceptions #use random module to randomize selection
Atheist: God is man made imagination, he doesn't exist!
Theist: It's okay, can you imagine anything else that doesn't exist?
Junior MD --- Python, C++ and PHP
Theist: It's okay, can you imagine anything else that doesn't exist?
Junior MD --- Python, C++ and PHP
•
•
Join Date: Dec 2008
Posts: 65
Reputation:
Solved Threads: 1
•
•
•
•
Yes, it's simple enough. The example given started out with mypocket = ("gum", "wallet", "old kleenex", "bus ticket") . Was there something unusual about this that prevented you from extending that from 4 items to 10? Theres 2 parts to that question.... >.>" did u not read it all?
That doesn't square with what you said in the original post ... you know ... the part that reads "I can't seem to figure it out." For all I know, English isn't your native language. Just wanted to make sure we start out with common definitions.
Also it appears you have not read the homework assistance announcement. Generally what goes on here is you post what code you have written (following syntax highlighting guidelines) and lots of folks will be glad to help. But most folks (evidently not all) want you to show some effort first.
Also it appears you have not read the homework assistance announcement. Generally what goes on here is you post what code you have written (following syntax highlighting guidelines) and lots of folks will be glad to help. But most folks (evidently not all) want you to show some effort first.
•
•
Join Date: Dec 2006
Posts: 1,008
Reputation:
Solved Threads: 285
I've flagged this as a bad post. Since this is the first time, hopefully it was done correctly. This was the message:
This post is from someone who posted a link to their homework assignment, with no attempt to code anything themselves, and then asked for the answer. Further, they berate someone for not reading the homework assignment completely. Any one who is too lazy to cut and paste the question into the forum should not criticize someone else. We don't want to encourage the attitude of, "I'll sit here on the veranda in my rocking chair while you go fetch the homework from the web for me, and then code the answer while I sit here rocking away". Obviously, this violates the "only help those who shown some effort" and also violates the "keep it pleasant" guidline.
This post is from someone who posted a link to their homework assignment, with no attempt to code anything themselves, and then asked for the answer. Further, they berate someone for not reading the homework assignment completely. Any one who is too lazy to cut and paste the question into the forum should not criticize someone else. We don't want to encourage the attitude of, "I'll sit here on the veranda in my rocking chair while you go fetch the homework from the web for me, and then code the answer while I sit here rocking away". Obviously, this violates the "only help those who shown some effort" and also violates the "keep it pleasant" guidline.
Last edited by woooee; Dec 3rd, 2008 at 6:03 pm.
•
•
•
•
That doesn't square with what you said in the original post ... you know ... the part that reads "I can't seem to figure it out." For all I know, English isn't your native language. Just wanted to make sure we start out with common definitions.
Also it appears you have not read the homework assistance announcement. Generally what goes on here is you post what code you have written (following syntax highlighting guidelines) and lots of folks will be glad to help. But most folks (evidently not all) want you to show some effort first.
May 'the Google' be with you!
![]() |
Similar Threads
- Starting Python (Python)
- Python Tuples and Mysql Query (MySQL)
- Python tuples and Sql query (Python)
- Tuple List (Python)
- Python and the JPEG Image File, Part 2, The Image (Python)
- sourcing a python config file? (Python)
- tuple or list? (Python)
Other Threads in the Python Forum
- Previous Thread: counting pixels in an image(ocr)
- Next Thread: Play Sounds at different Speeds
| Thread Tools | Search this Thread |
address aliased anydbm app bash beginner bits calling casino changecolor cipher clear conversion coordinates corners count cturtle curves definedlines development dictionary digital dynamic events examples excel external feet file float format function gui handling hints homework iframe images import input java keycontrol line linux list lists loan loop matching mouse multiple number numbers output parsing path port prime programming projects py py2exe pygame pymailer python random rational raw_input recursion recursive scrolledtext searchingfile shebang signal singleton split string strings tails terminal text threading time tlapse tooltip tuple tutorial type ubuntu unicode url urllib urllib2 valueerror variable web-scrape whileloop word wxpython xlwt






