Skip to content

Latest commit

 

History

History
31 lines (26 loc) · 3.7 KB

Python_basics_practice_exercise.md

File metadata and controls

31 lines (26 loc) · 3.7 KB
  1. Write a program to generate a Fibonacci series

  2. In cryptography, a Caesar cipher is a very simple encryption techniques in which each letter in the plain text is replaced by a letter some fixed number of positions down the alphabet. For example, with a shift of 3, A would be replaced by D, B would become E, and so on. The method is named after Julius Caesar, who used it to communicate with his generals. ROT-13 ("rotate by 13 places") is a widely used example of a Caesar cipher where the shift is 13. In Python, the key for ROT-13 may be represented by means of the following dictionary: key = {'a':'n', 'b':'o', 'c':'p', 'd':'q', 'e':'r', 'f':'s', 'g':'t', 'h':'u', 'i':'v', 'j':'w', 'k':'x', 'l':'y', 'm':'z', 'n':'a', 'o':'b', 'p':'c', 'q':'d', 'r':'e', 's':'f', 't':'g', 'u':'h', 'v':'i', 'w':'j', 'x':'k', 'y':'l', 'z':'m', 'A':'N', 'B':'O', 'C':'P', 'D':'Q', 'E':'R', 'F':'S', 'G':'T', 'H':'U', 'I':'V', 'J':'W', 'K':'X', 'L':'Y', 'M':'Z', 'N':'A', 'O':'B', 'P':'C', 'Q':'D', 'R':'E', 'S':'F', 'T':'G', 'U':'H', 'V':'I', 'W':'J', 'X':'K', 'Y':'L', 'Z':'M'} Your task in this exercise is to implement an encoder/decoder of ROT-13. Once you're done, you will be able to read the following secret message: Pnrfne pvcure zrgubq vf anzrq nsgre Whyvhf Pnrfne! Note that since English has 26 characters, your ROT-13 program will be able to both encode and decode texts written in English.

  3. You are given a string of text. Clean the text to remove for any punctuations, extra white spaces, tab characters and count the number of words within the text. After this, count the unique number of words in a text and the frequency of occurrence of each word in that text. Finally, you are provided a dictionary. Using the dictionary, count the words and frequency of words in the dictionary that occur in text. Why Apple Is In My Retirement Portfolio Summary Apple is a rare bird of a stock. It offers shareholders enormous growth, and could potentially become the next great dividend stock. The company is the largest &&&&&& public company in the world, surpassing Exxon Mobil. The raw fundamentals of this company are virtually incomparable. Over the last several years, I have been all over the board when it comes to Apple (AAPL). During its parabolic ------ ----- - - - - - rise in price about 2 years ago, I wrote several articles urging investors to take some chips off the table, and then when it hit some low points, I suggested it might be time to buy the stock, which I did, but not just for my growth portfolio. The stock seemed to have become a value stock with a rather strong + + + + + + dividend, so I placed it in 3 of my portfolios, and have held it ever since in 2 of the 3 portfolios I currently manage. As of several months ago, I added APPL to my newest retirement portfolio, "Buy The Dips Portfolio", or BTDP. The stock is now [ [ [ [ [ going to be held for the very long term in at least 3 out of 4 of my various portfolios, mainly for dividend income investors, but with an eye towards another strong round of growth. Apple Is More Than A Reborn Growth Stock, It Is Also A Future Dividend Champion The recent shareholder-friendly moves ] ] ] ] ] ] that Apple has made should ignite even more intense interest in the stock for both dividend-seeking investors, as well as for growth investors.

  4. Write a python program which reads a text file and performs the following operations: a) Arrange the words in every line in reverse order and print them b) Count the frequency of each word in the file and print them in alphabetical order (by words). The output should have word followed by its frequency count. Convert all the words in the file into lowercase to avoid duplication of words. c) Print top 20 most frequently used words