Introduction to Python : Contest Details

63 views
Skip to first unread message

Anil

unread,
Jan 16, 2013, 2:06:06 PM1/16/13
to wncc...@googlegroups.com
Hi All,

Today we had a very successful hands on session on Python. Entire NSL Hall was jam packed with students enthusiastic about Python.

As said after the workshop, we are running a contest for people who attended today's workshop. Here are some questions for you to try - fire up your python shell and try to solve as many as you can. 

We have two laptop bags to give away. You need to have solved at-least 10 q to be eligible for the prize. Once you have solved 10 q - send in a mail to an...@stab-iitb.org with the question number and solution. Should there be more than 2 contenders for the prize, winner will be selected using random.org

Deadline for this is Sunday 20th Jan 11:59 pm
  1. Write a function that takes a list as input and returns the minimum element of the list. Try to do it in different ways! Don't use the built-in functions!
  2. Write a function to find the number of words in a sentence. Try to do it in one line
  3. Write a function to find the factorial of a positive integer. Try to do it in one line!
  4. Write a function to add only the even elements of a list.
  5. Write a function to add all numbers between 1 and 999 (both included) which are divisible by either 3 or 5. Try to do it in one line!
  6. Write a function to return all prefix strings of the string 'aaababbbabababbabbbababbaa' which do not end in 'a'. Try to do it in one line!
  7. Write a function to find the sum of digits of a number. Try to do it in one line! Try to do it with and without using dictionaries.
  8. Write a function to remove repeated elements from a list. Do it in different ways.
  9. Write a function that takes a string of digits as input from a user, converts it to a number, and checks if it is a palindrome
  10. Write a function that takes a string as input from the user and returns a string with the alternate digits dropped
  11. Write a function that takes a number as input and checks if it is prime or not. Make it as fast as possible.
  12. Write a function that takes a list and duplicates each element of it e.g. [1,2,3,3] => [1,1,2,2,3,3,3,3]
  13. Write a function that takes a string as input and returns a string containing only the characters at odd positions e.g. 'abcd' => 'ac'
  14. Write a function that takes a list as input and returns a list that has the same elements as the input list, but the right half of the output list is sorted whereas the left halves are reverse sorted. e.g. [4,7,9,3,2,6,5,1] => [9,7,4,3,1,2,5,6] as the left half of the input list is [4,7,9,3] and the right half of the input list is [2,6,5,1]
  15. Write a function that, given a string, removes from the string any * character, or any character that's one to the left or one to the right of a * character. Examples:  "adf*lp" --> "adp"
      "a*o" --> ""
      "*dech*" --> "ec"
      "de**po" --> "do"
      "sa*n*ti" --> "si"
      "abc" --> "abc"
  16. Write a function to return all permutations of a given string. Don't cheat by using the permutations function in the standard library!
  17. Write a function that takes a number between 0 and 1 as input (call it x) and returns a random string consisting of 0s and 1s such that the probability of getting '1' when a character is randomly chosen from the string = x.
Thanks to Rohan Prinja for taking this session.

Anil Shanbhag
Manager, WnCC

ujjwal bahare

unread,
Jan 17, 2013, 12:57:16 AM1/17/13
to wncc...@googlegroups.com

by doing in one line
u mean to write program that solves d question in one
because we might need some variables to do that

--
--
The website for the club is http://stab-iitb.org/wncc
To post to this group, send email to wncc...@googlegroups.com
 
 
 

Anil

unread,
Jan 17, 2013, 3:47:50 AM1/17/13
to wncc...@googlegroups.com
@Ujjwal Its 'try doing in one line'
If you have just started maybe you might not be able to do it but no worries. As its try you might as well submit a multi-line code. 


On Thursday, January 17, 2013 11:27:16 AM UTC+5:30, ujjwal bahare wrote:

by doing in one line
u mean to write program that solves d question in one
because we might need some variables to do that

On Jan 17, 2013 12:36 AM, "Anil" <anilas...@gmail.com> wrote:
Hi All,

Today we had a very successful hands on session on Python. Entire NSL Hall was jam packed with students enthusiastic about Python.

As said after the workshop, we are running a contest for people who attended today's workshop. Here are some questions for you to try - fire up your python shell and try to solve as many as you can. 

We have two laptop bags to give away. You need to have solved at-least 10 q to be eligible for the prize. Once you have solved 10 q - send in a mail to a...@stab-iitb.org with the question number and solution. Should there be more than 2 contenders for the prize, winner will be selected using random.org

Anil

unread,
Jan 18, 2013, 9:55:24 AM1/18/13
to wncc...@googlegroups.com
I must say we have our first entry submitted :) 
Deadline is still 2 days away. 

Anil

unread,
Jan 20, 2013, 4:47:51 AM1/20/13
to wncc...@googlegroups.com
Last day today
All entries till today midnight will be considered
Reply all
Reply to author
Forward
0 new messages