This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
software_carpentry [2013/06/02 09:53] sandeep |
software_carpentry [2013/06/07 08:38] animesh |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | =====Basic===== | + | === Basic === |
=====Editors==== | =====Editors==== | ||
- Create a file using cat with all the names of your friends. | - Create a file using cat with all the names of your friends. | ||
Line 34: | Line 34: | ||
- Write a function called "morph" which takes a string and replaces all a's in the string and replaces them with o's and replaces all e's with i's. | - Write a function called "morph" which takes a string and replaces all a's in the string and replaces them with o's and replaces all e's with i's. | ||
- Write a function called "common" which takes two lists l1 and l2 and returns the common items in a list. | - Write a function called "common" which takes two lists l1 and l2 and returns the common items in a list. | ||
- | ===== Intermediate ===== | + | === Intermediate === |
- | * Here is a description of the “Lucky 7” Game: | + | - Here is a description of the “Lucky 7” Game: |
- | You start of by asking the user to choose from 3 sets (Hint :: Use raw_input) | + | You start of by asking the user to choose from 3 sets (Hint :: Use raw_input) |
- | - Any number below 7 (0-7) | + | - Any number below 7 (0-7) |
- | - Exactly 7 | + | - Exactly 7 |
- | - Any number above 7 (7-12) | + | - Any number above 7 (7-12) |
- | After the user chooses, you have to roll your dice and see the outcome | + | After the user chooses, you have to roll your dice and see the outcome |
- | - If the number on the dice is < 7 and user chooses i, then he wins. Else, he loses | + | - If the number on the dice is < 7 and user chooses 1, then he wins. Else, he loses |
- | - If the number on the dice is = 7 and the user chooses ii, he wins, Else he loses | + | - If the number on the dice is = 7 and the user chooses 2, he wins, Else he loses |
- | - If the number on the dice is > 7 and the user chooses iii, he wins, Else he loses | + | - If the number on the dice is > 7 and the user chooses 3, he wins, Else he loses |
Task : Write a python program to stimulate the lucky 7 program .. | Task : Write a python program to stimulate the lucky 7 program .. | ||
Hint : [[python_reference#random|Use random module]] | Hint : [[python_reference#random|Use random module]] | ||
- | * Write a function called "shift" which takes a list l1 and a number n. The function should insert n number of zeros in front of the list and discard the last n number of digits already present in the list. | + | - Write a function called "shift" which takes a list l1 and a number n. The function should insert n number of zeros in front of the list and discard the last n number of digits already present in the list. |
+ | * shift([1,2,3,4],1) must return [0,1,2,3] | ||
+ | * shift([1,2,3,4],2) must return [0,0,1,2] | ||
+ | * | ||
* | * |