Python Programming Basics - Assignment

Problem Statement:

Write a function that should count word occurance in file.

  1. Define function 'countWord' which will accept two arguments, filepath and word to find inside file.
  2. You can create your own file or you can use given testfile.txt inside files directory.
  3. Calculate word occurance. Function should return count.
  4. Function should pass all test cases.

Instructions:

  • Program should be written in file count_word.py

  • Function name should be countWord.

  • Input

     File = Learning from machine, machine learning.
    
     Type:  File path and string
     Value: Word = learning (case sensative)
    
  • Expected Output

      Type:  Integer
      Value: 1