Question

In: Computer Science

1.   Define each of the following fundamental concepts Interpreted vs. Compiled Languages Interpretive Overhead Scripting (Procedural) vs....

1.   Define each of the following fundamental concepts

  1. Interpreted vs. Compiled Languages
  2. Interpretive Overhead
  3. Scripting (Procedural) vs. Object Orientation vs. Logic Programing vs. Event Driven Programming Paradigms
  4. Programming Libraries/Modules
  5. Command Line (Prompt)
  6. ASCII
  7. Functions
  8. Control Flow
  9. Hashes/Dictionaries
  10. List Comprehension

True or False

2.   A dictionary is a random-access data structure.

3.   An array is a sequential access data structure.

4.   Using functions to isolate code is a good programming practice.

5.   Lexicographical ordering starts by comparing the first letters of two strings to determine the order.

6.   Standard Input in Perl and Python is the keyboard.

7.   Standard Output in Perl and Python is the printer.

8.   The character "!" comes after "M" in the ASCII table.

9.   Regular expressions are used to process text.

10. In Perl, the last calculation performed in a subroutine is returned by the subroutine, unless an explicit return value is provided with the return keyword.

11. Python numpy arrays are homogenous data structures.

12. A Python list is a mutable, random access data structure of mixed type.

13. Dictionaries are useful to store pairs of data sets which are related and of the same length.

Basic Statistical Functions

14. Come up with a function in Python to compute the sample mean of a list of numbers. The return value should be the sample mean and the input value should be the list of numbers. Do not use a built-in function for the mean. Show an example of your function in use.   

The sample standard deviation sN is defined as the square root of the sample variance of a set of N values.

15.  come up with a function in Python to compute the sample standard deviation of a list of numbers. The return value should be the sample standard deviation and the input value should be the list of numbers. Do not use a built-in function for the standard deviation. Show an example of your function in use.   

Basic Text Processing

16. Come up with a function in Python to take in a piece of sample text via a long string (you pick the string) and to output a dictionary with each word as a key and it's frequency (the number of times it occurred in the original string) as the value. Show an example of your function in use. Be sure to strip out any punctuation.

17. Come up with a function in Python which removes a set of common words from a long piece of text. Be sure to strip out any punctuation. The common words to be removed are:

                    a, an, as, at, by, for, in, is, it, of, that, this, to, was, will, the

These are typical words which are considered to have low semantic value.

Process each paragraph provided below individually. Your end result for each paragraph should be a string or list containing the processed paragraph with the common words and punctuation removed. It is not required to put the text samples into a file (you can simply copy and paste into a string variable inside your Python script).

For the text samples to process, use the following (taken from the official Python tutorial):

If you do much work on computers, eventually you find that there's some task you'd like to automate. For example, you may wish to perform a search-and-replace over a large number of text files, or rename and rearrange a bunch of photo files in a complicated way. Perhaps you'd like to come up with a small custom database, or a specialized GUI application, or a simple game.

If you're a professional software developer, you may have to work with several C/C++/Java libraries but find the usual write/compile/test/re-compile cycle is too slow. Perhaps you're writing a test suite for such a library and find writing the testing code a tedious task. Or maybe you've written a program that could use an extension language, and you don't want to design and implement a whole new language for your application.

You could come up with a Unix shell script or Windows batch files for some of these tasks, but shell scripts are best at moving around files and changing text data, not well-suited for GUI applications or games. You could come up with a C/C++/Java program, but it can take a lot of development time to get even a first-draft program. Python is simpler to use, available on Windows, Mac OS X, and Unix operating systems, and will help you get the job done more quickly.

Python is simple to use, but it is a real programming language, offering much more structure and support for large programs than shell scripts or batch files can offer. On the other hand, Python also offers much more error checking than C, and, being a very-high-level language, it has high-level data types built in, such as flexible arrays and dictionaries. Because of its more general data types Python is applicable to a much larger problem domain than Awk or even Perl, yet many things are at least as easy in Python as in those languages.

Python allows you to split your program into modules that can be reused in other Python programs. It comes with a large collection of standard modules that you can use as the basis of your programs — or as examples to start learning to program in Python. Some of these modules provide things like file I/O, system calls, sockets, and even interfaces to graphical user interface toolkits like Tk.

Python is an interpreted language, which can save you considerable time during program development because no compilation and linking is necessary. The interpreter can be used interactively, which makes it easy to experiment with features of the language, to write throw-away programs, or to test functions during bottom-up program development. It is also a handy desk calculator.

21. Install a Python module that is not included with the Anaconda Distribution. Explain how you installed the module and take a screen shot of the install.  

Solutions

Expert Solution

Note - As per the protocol i am answering only 1st part of this subjective question.

Interpreted vs. Compiled Languages

In Interpreted languages source code is translated into machine code line by line. It is slower as both compilation and execution takes place simultaneously. Example C, C++

In Compiled languages whole source code is converted into machine code at once. Here compilation is done before execution so programs run faster. PHP, python MATLAB.

Interpretive overhead

Interpretive overhead is related to Interpreted compilers. An interpreter takes the source code and processes it line by line. In this processing it can break down the source code into smaller executable code, checking syntax, performing data conversion and other activities to give the final output. All these activities are not a part of execution of source code so they are considered as interpretive overhead. There is no sich thing called compilation overhead as program is converted into machine code prior to its execution.

There are various programming paradigm approaches-

Scripting (Procedural language) - It continuously break down the program into smaller subroutines or subprocedures until the program is simple enough to be solved. Any procedure can be called anytime during program execution. This process is called functional decomposition. Example COBOL, FORTRAN

Object oriented programming languages- These languages are based on the concept of objects and classes. Objects contain data and methods. The objects are called to perform certain activities during program execution. Example JAVA, C++

Logical programming- it is based on the approach of formal logic. There are not instructions but logical assertions are made for the problem and facts are established. Then this programming paradigm uses everything to make the established logic and facts true.

Example - logic- "F is true if B2, B4 and B3 are true."

Facts - "F is true."

Event driven programming- it is based on events. The code does not run from start to end rather the program Waits for certain events to occur to run the code(callbacks) as a response to those events. The program can choose to respond or ignore the event. This event can be triggered by user like button click or mouse movement or it can be internal as well like set timer.

Programming Libraries/Modules

Sometime we need to break a code into smaller executable modules/functions and these modules can be reused in the program. We can put these modules into separate file called library. A library is a collection of pre-compiled and reusable programming modules. Any program can use these modules by importing them from library without rewriting or duplicating them in the source code. These libraries are compiled separately from the main program.

Example random is a library in python that generates a random integer. We can import it in the program like this: import random.

ASCII - American Standard Code for Information Interchange is a character encoding standard. It uses numeric codes to represent characters in a program. These characters can be upper and lower case English alphabets, special symbols, numbers 0-9 etc. It uses 7 bits to represent each character. A standard ASCII can represent 128 characters. Example- ASCII code for uppercase M is 77.

Functions - function is a collection of reusable codes that perform specific task in the program. There are built in functions like print() and user defined functions which are created by user. We can pass data known as parameters to functions and return an output.

Example of function in python :

def my_function():
  print("Hello ")

Control flow is the flow of events or order in which statements of a program are executed.

Dictionary - It is also called hash, hashmap or object in different. languages. Each item is in the form of key-value pair in a dictionary.The key is used to access the item.

List Comprehension is a way of constructing lists based on existing lists.

structure of a list comprehension in python:

output_list = [output_exp for var in input_list if (var satisfies this condition)]


Related Solutions

What is different between procedural and object-oriented programming? Match each of the following OOP concepts with...
What is different between procedural and object-oriented programming? Match each of the following OOP concepts with its example/description. Question 2 options: 12345678 Providing a way for an entity to behave in several ways OR providing multiple entities to be treated in a similar way 12345678 A key way of saving having to retype a lot of code for similar but different objects 12345678 The removal of non-essential information 12345678 Allowing which function to be called by an object to be...
Define each of the following terms and concepts and explain their significance in the economics of...
Define each of the following terms and concepts and explain their significance in the economics of natural resources. In your discussion of each term/concept, give relevant examples. [3 marks] Total willingness to pay [3 marks] Net present value [3 marks] Social costs [3 marks] Efficiency [3 marks] Private good [3 marks] Market failure [3 marks] Discounting
Define each of the following terms and concepts and explain their significance in the economics of...
Define each of the following terms and concepts and explain their significance in the economics of natural resources. In your discussion of each term/concept, give relevant examples. a. [3 marks] Natural resource rents b. [3 marks] Public good c. [3 marks] intertemporal efficiency d. [3 marks] Nonrenewable resources e. [3 marks] Maximum sustainable yield f. [3 marks] Incentive-based policies
define the following concepts and discuss the application of each: 1. Marketing Management 2. Consumers Value...
define the following concepts and discuss the application of each: 1. Marketing Management 2. Consumers Value 3. Marketers 4. Marketing ethics please define in detail and please provide the references for the work.
Define - in your own words - each of the following related concepts with the costs...
Define - in your own words - each of the following related concepts with the costs of a product or service: to. F. Product costs g. Raw material / Direct material h. Direct labor / Direct labor i. Indirect costs (manufacturing overhead) j. Selling Costs / Marketing Costs k. General and administrative costs 2. Mention an example of each of the concepts, behaviors and / or characteristics of the costs defined in numeral 1.
Define the following accounting concepts and explain for each their implications for the preparation of financial...
Define the following accounting concepts and explain for each their implications for the preparation of financial statement 1. business entity concept 2. going concern 3. materiality 4. fair representation
Briefly define each of the following concepts and briefly discuss the significance/relevance/use of each in cost...
Briefly define each of the following concepts and briefly discuss the significance/relevance/use of each in cost benefit analysis: - discount rate - replication method - net present value - horizon value - internal rate of return - sensitivity analysis
Briefly define each of the following concepts and briefly discuss the significance/relevance/use of each in cost...
Briefly define each of the following concepts and briefly discuss the significance/relevance/use of each in cost benefit analysis: - discount rate - replication method - net present value - horizon value - internal rate of return - sensitivity analysis
Define and explain the significance of each of the following concepts: modern state and nation-sovereignty
Define and explain the significance of each of the following concepts: modern state and nation-sovereignty
Give a grammar that generates each of the following languages: (1) L = {a2n cm bm...
Give a grammar that generates each of the following languages: (1) L = {a2n cm bm | m ≥ 0, n ≥ 0} (2) L = {an b2m cn | m ≥ 0, n ≥ 0} (3) L = {an bm | n+m is even} (4) L = {an bm | n ≤ m+3} (5) The complement of the language L = {anbn | n ≥ 0}
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT