Python Learning Week 2 (Solution)


Loops, Function, Tuples, Lists and Dictionary in Python

Task 1

Write a program of simple calculator program. Follow the steps below,

  • Declare and define a function name Menu which displays a list of choices for user such as addition, subtraction, multiplication etc. It takes the choice from user as an input and return.

  • Define and declare a separate function for each choice.

  • In the main body of the program call respective function depending on user’s choice.

  • Program should not terminate till user chooses last option that is “Quit”.

uDExdF3hGWnc8Kf7ujIvc5enz8eFLzAQAWByH+fwocIA9hKVHMAAAAAElFTkSuQmCC - Python Learning Week 2 (Solution)

FA02IFXrMkQAAAABJRU5ErkJggg== - Python Learning Week 2 (Solution)


Task 2

Write a method to calculate Fibonacci Series up to ‘n’ points. After calculating the series, the method should return to the main.





JTaggAAAAASUVORK5CYII= - Python Learning Week 2 (Solution)


3kCnJ91bSlSAAAAAElFTkSuQmCC - Python Learning Week 2 (Solution)


Task 3

Write a program to calculate factorial of a number entered by user.


a3ySQZxTXrv408w3F941GMs+yesqUKVPuQtnNGH0ZZNH2vvVt2bf+KJbbjIw8xxmRJwAAQBsgTwAAgJogTwAAgJogTwAAgJogTwAAgJogTwAAgJogTwAAgJogTwAAgJogTwAAgJogTwAAgJogTwAAgJogTwAAgJogTwAAgJogTwAAgJogTwAAgJogTwAAgJogTwAAgJogTwAAgJogTwAAgJogTwAAgJogTwAAgJogTwAAgJogTwAAgJogTwAAgJogTwAAgJogTwAAgJogTwAAgFoo9f8Bo3RoDAlpCp4AAAAASUVORK5CYII= - Python Learning Week 2 (Solution)


9jjYyabKo6hQAAAABJRU5ErkJggg== - Python Learning Week 2 (Solution)


Task 4

Write a program that lets the user enter in some English text, then convert the text to Pig-latin.

BiIixpbBWE+wAAAAAElFTkSuQmCC - Python Learning Week 2 (Solution)



ovo96IeXfmgAAAAASUVORK5CYII= - Python Learning Week 2 (Solution)


Task 5 (Home Task)

Splits the string |text| by whitespace and returns two things as a pair: the set of words that occur the maximum number of times, and their count, i.e. (set of words that occur the most number of times, that maximum number/count) You might find it useful to use collections. Counter().​​ 





wOysmPpzxxX4gAAAABJRU5ErkJggg== - Python Learning Week 2 (Solution)