Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Math Questions

Status
Not open for further replies.

eamc

Technical User
Sep 3, 2001
83
0
0
US
1) What is the Python statement for nCr, i.e. the number of combinations of n things taken r at a time?

2) What is the formula for counting the number of elements in a set, e.g. 3 for set('a','b','c') ?

Thanks.
 
1) There is not a built in function for combinations, but there are modules that people have written for python that provide that functionality. Google for 'Python combination permutation' and you should find code examples.

2) If you have a list of items (set), then len()will return the number of elements.

[red]"... isn't sanity really just a one trick pony anyway?! I mean, all you get is one trick, rational thinking, but when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick[/red]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top