Prints out the number of function definitions found

Assignment Help Computer Engineering
Reference no: EM132212236

Write Python code:

Write a program that reads a Python source file and prints out the number of function definitions found in the source file.

The task is accomplished by counting how many times you detect the reserved word def in a given file.

Assume the input file is a valid Python program and does not include any comments.

Use this starter Python code:

def count_def(source):
print(source) ## test print;

return 10 ## MODIFY this

while True:
filename = input("Python Source File: ")

if filename == "": break

file = open(filename, "r")

source = file.read()

def_cnt = count_def(source)

print(def_cnt)

Reference no: EM132212236

Questions Cloud

Adoption of industry standard for internet systems : What are the main barriers to the adoption of an industry standard for internet systems.
Post a brief description of the vulnerable population : Post a brief description of the disadvantaged or vulnerable population you selected. Then, explain three of the greatest challenges this population faces.
Prepare an unadjusted trial balance : 700029 FINANCIAL ACCOUNTING APPLICATIONS - Prepare an unadjusted trial balance on the worksheet provided (see Excel file Worksheet Tab)
Discuss the potential role of strategic cost management : Discuss the potential role of strategic cost management in the operations of your organisation
Prints out the number of function definitions found : Write a program that reads a Python source file and prints out the number of function definitions found in the source file.
Develop your strategic goals : Develop your strategic goals (at least three). The goals must address the following: Address issues such as globalization and how those issues might impact.
Determine profile of one of starbucks target market segment : How to determine the profile of one of Starbucks’ target market segment
Create a template file in your module : Write a puppet module to accomplish the following: Automatically install and run apache with a default HTML page that gives information about the system.
Create a single letter frequency distribution : Write a Python function that takes a filename and creates a single letter frequency distribution for all the chars (i.e. bytes) occuring in the file.

Reviews

Write a Review

Computer Engineering Questions & Answers

  Write a program that simulate the bounded-buffer

Have your program produce an item with a random delay interval between one and five seconds for each item produced.

  Define difference between logical and physical address space

Why is the Hamming error-correcting code mechanism not supplied as standard in PCs?

  Write an assembly language program that prints your name

Write an assembly language program that prints your first name on the screen. Use the .ASCII pseudo-op to store the characters at the bottom of your program.

  Evaluation of vpn business sites using cisco devices

Prepare a technical plan for your chosen case study - Write down all the security and business objectives required based on give case study - The case studies focus on the design, implementation, and the evaluation of VPN business sites using Cisco d..

  Write a program in assembly that will take ten integers

Write a program in assembly (kip irvine32)language that will take ten integers (32 bit) in an array.

  Define a class student which will have two more properties

Define a class "Human" which will have the follwing properties: (7) age (int) gender.

  Prepare an 8-10-page report in word this report should

prepare an 8-10-page report in word. this report should include a project history of your recent trillo apparel

  Write a mips assembly program

Write a MIPS assembly program that will make use of the function count above as follows: Let's assume you are asked to code a car-finding system for a local parking lot: You are provided with the location of all the cars in the parking lot. The infor..

  Design and implementation of demonstration system

ICT705 - Data and System Integration - University of the Sunshine Coast - You are required to write a report explaining the key concepts around the design

  What strengths make each protocol suitable

Describe the protocols, and provide examples of where they might be effectively used. What strengths make each protocol suitable to the example application?

  Write application that instantiates five librarybook objects

Write an application that instantiates five LibraryBook objects and prompts the user for values for the data fields. The objects should be stored in either an Array or an ArrayList.

  Program to calculate salary of family members

Suppose that your family has 10 members. Suppose further that every family member has the particular amount of the savings. Your task is to find: The total amount of savings that the family has, as a whole and To find who has the largest savings.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd