Programming embedded systems-programming models, Python Programming

Assignment Help:


Programming models

Just  as there  are several methods for organizing entire  software systems, there  are  different strategies for formally expressing computational processes within those structures.

1.3.2.1 Imperative computation

Most  of you  have  probably been  exposed to an  imperative model  of computer application, in which  we taught  of programs as giving  a sequential set of instructions to the computer to work something.  And, fact that  is how  the internals of the processors of computers are typically created. So, in C or JAVA or C++, you write  typically methods that has  of lists of instructions to the computer:

1.  Put this value  in this variable

2.  Square  the variable

3.  Divide  it by pi

4.  If the result  is larger than  1, return the result

In this model  of computation, the primitive computational elements are basic arithmetic operations  and  assignment instructions. We may combine the elements using  sequences of statements, and  functional  structures such  as if, for, and  while.  We can give away  from  the details  of a computation by defining a procedure that  does  it.  Now,  the person only  requires  to know  the specification of the method, but not the implementation information,  in order  to use it.

 

 

 

 

1.3.2.2 Functional computation

 

Another style  of programming is the  functional model.   In this  model,  we  gain  power through function invokes.  Rather  than  describing  the computer to do things,  we ask it questions: What is 4 + 5? What is the square root of 6? What is the largest  element of the list?

These questions can all be expressed as asking  for the value  of a function applied to some arguments.  But where do the method come from? The answer is, from other methods. We initiate with some set of basic methods (like "plus"), and use them  to construct more complex  functions.

This method would not be powerful without the mechanisms of conditional evaluation and  re­ cursion.  Conditional functions tells one  question under some  situations and  another question under other situations. Recursion is a method that lets the definition of a function refer to the function being described. Recursion is as useful as iteration.

In this model  of computation, the primitive computational elements are typically basic arithmetic and  list functions. We combine components using function composition (using  the output of one function as the  input to other function), if, and  recursion.  We use  method definition as a method of abstraction, and  the concept  of higher-order functions (passing functions as arguments to other functions) as a way of capturing common high-level patterns.

 

1.3.2.3 Data structures

 

In either type of asking  the computer to perform work  for us, we have another kind of modularity and abstraction, which  is centered around the organization of data.

 

At the most  primitive level, computers operate on collections of (usually 32 or 64) bits.  We may halt such  a collection  of bits  as representing different things:   a positive number, a signed value number, a ?oating-point value, a Boolean number (false or true),  characters, or an address of some  other  data  in the memory of the system. Python provides us the ability  to work directly with all of those primitives.

 

There is only so much you can do with a single value, though. We could like to create computer programs that perform on representations of documents or maps  or circuits or social networks. To do so, we require to aggregate primitive data  elements into more complex  data structures.  These can added arrays, lists,  dictionaries, and other data structure of our own devising.

Here,  again,  we  gain  the  power of abstraction.  We may prepare  programs that  do  operations on a data  structure representing a social network, as like, without having to work about  the details  of how the social network is represented in terms  of bits in the machine.

 

1.3.2.4 Object-oriented programming: computation + data structures

 

Object-oriented programming is a model  that  gives the ideas  of modularity and  abstraction to execution and data  at the same time.

An object is a data  structure, together with  a set of procedures that  operate on the  data.   Basic methods may be written in an imperative or a functional model, but in the end there is imperative assignment to state variables in the object.

One major  new  type  of abstraction in OO programming is "generic" programming. It may  be that all objects have a method called print related with  them.  So, we may ask any object to print  itself, without knowing  how  it is created. Or, in a graphics system, we may have several of different objects that know their x, y coordinates on the screen.  So each of them can be asked,  in the similar way,  to say what  their  position is, even though they may  be shown very differently inside  the objects.

In addition, most object-oriented systems support inheritance, which  is a way to make new types of objects by saying  that  they  are mostly  like another type  of object, but  with  some  errors. This is another way to take advantage of abstraction.

 

Programming  languages

Python as well as other  modern programming languages, such  as Ruby, Java and  C++, support all of these programming models. The programme needs  to choose which  programming model best suits the program. This is a point that we will give to throughout the course.

 


Related Discussions:- Programming embedded systems-programming models

Example of python code, Worked example 1   Let's examine what  happens...

Worked example 1   Let's examine what  happens when  we compute the following Python code:   def p(x, y): z = x*x - y return z + 1/z   >>> p(1.0, 2.0) -2.0

Interaction and debugging, We encourage you to adopt an interactive style o...

We encourage you to adopt an interactive style of debugging and programming. Use the Python shell a lot. Write short pieces of code and check them.  It is much  simpler to test the

Expressions and assignment, Expressions and assignment We can think of...

Expressions and assignment We can think of most computer programs as performing some sort of transformation on data.  Our code may get as input the exam scores of everyone in

Cps translator for python, Your task is to construct a translator from the ...

Your task is to construct a translator from the subset of Python in Project 3 intocontinuation-passing style (CPS). Of course, the expected way of accomplishing this is to trans

Lists, Python has  a built-in list data  structure that  is easy  to use  a...

Python has  a built-in list data  structure that  is easy  to use  and  incredibly convenient.  So, for that point, you can say >>> y = [1, 2, 3] >>> y[0] 1 >>> y[2]

Python programs, Python programs Every  general-purpose computer has a...

Python programs Every  general-purpose computer has a various detailed design, which  defines  that  the way  its program requires  to be specified is different. The "machine

CIS, Define a function that draws a pentagon of a size you provide when you...

Define a function that draws a pentagon of a size you provide when you call the function. Include a ''''''docstring'''''' as the first line of the function''s body — it tells the p

Structured data, Structured data We will often  want  to work  with  l...

Structured data We will often  want  to work  with  large  groups of data.   Rather  than  providing  each  number its own  value,  we need  to manage the data  into natural s

#title.display of vanderwaals isotherm, draw the variation of pressure with...

draw the variation of pressure with volume of a real gas at temperatures lower than its critical temperature.also draw its surface of discontinuity

Top-down approach, what are the issues assciated with top-down analysis

what are the issues assciated with top-down analysis

Write Your Message!

Captcha
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