Programmer does not have to use the def statement

Assignment Help Python Programming
Reference no: EM13164477

Consider a very simple programming language named Z+-. The Z+- programming language has the following features:

  • Every program can declare integer variables, using case-sensitive alphabetic identifiers. This is done using the DEF statement:

               DEF hello ;

    All declared variables are automatically initialized to 0.
  • At the end of the program, all the variables are printed to the console in alphabetical order (this is the only form of output). Again, there are no explicit statements to do this printing; it is done implicitly.
  • The right-hand side of a simple assignment statement (i.e., =) is either a variable name or unsigned integer. For example, the following are valid:

A = 12 ;

A = B ;

  • There are two assignment statements: +=, *=, and -=. These have their usual meaning:

A += 34 ;

A *= B ;

  • Every statement is terminated by a semi-colon.
  • There is a loop statement - FOR - whose body contains at least one simple statement (i.e., no nested loops), which are on presented on one line. The keyword FOR is followed by a number, which indicates the number of times to execute the loop. Following this number is a sequence of statements defining the loop's body, followed by the word ENDFOR.
  • Z+- programs must have at least one space separating all lexical elements.


Here is an example Z+- program:

DEF A ;
DEF B ;
A = 1 ;

FOR 5 B += A ; A *= 2 ; ENDFOR

A += 1000 ;

This program's output is:

A=1032

B=31

An equivalent Java program would be:

public static void main(String [] args)

{

int A=0;
     int B=0;

A = 1;

for (int i=0; i<5; i++) {

B += A;

A *= 2;

}

A += 1000;

     System.out.println("A=" + A);

System.out.println("B=" + B);

}

Z+- did not acquire any faithful users; therefore, the designer developed Z+-+. Z+-+ has the following features:

  • Unlike Z+-, the programmer does not have to use the DEF statement to create a variable. Instead, the programmer can simply use the variable. The first use of the variable creates it and initializes it to 0.
  • Z+-+ for loops can be nested:

FOR 5 B += A ; A *= 2 ; FOR 10 A += B ; ENDFOR ENDFOR

  • You may assume that the programs are syntactically correct and will not cause arithmetic errors.

Reference no: EM13164477

Questions Cloud

State what is the reaction order with respect to no : Plot NO2 versus time, ln NO2 vs time, and 1/NO2 vs time. Which graph yields the best straight line? what is the reaction order with respect to NO2? Briefly explain
How many molecules of ethanol are present : How many molecules of ethanol are present in 125mL of ethanol? The density of ethanol is 0.789g/cm^3.
State the normal boiling point of ethanol : The normal boiling point of ethanol (C2H5OH) is 78.3 °C and its molar enthalpy of vaporization is 38.56 kJ/mol. What is the change in entropy in the system in J/K when 62.2 grams of ethanol
Design, write, and test a program : Design, write, and test a program that represents some of the aspects of a student
Programmer does not have to use the def statement : Unlike Z+-, the programmer does not have to use the DEF statement to create a variable. Instead, the programmer can simply use the variable. The first use of the variable creates it and initializes it to 0.
State the complete eigen-function of the molecule : Before the collision what is the complete Eigen-function of the molecule? assuming the surface is located at x=0, and V (x =0)=0 and tha tthe molecule is located at a position X>>0. which means the molecule can be treated as a free mass in the re..
Implement a class to represent a matrix : Implement a class to represent a matrix. While doing this exercise, you are allowed only to use C++ primitive types and arrays. You may not use STL in your Matrix definition. You must use dynamic memory.
A lock variable not a good solution for mutual exclusion : why is busy waiting on a lock variable not a good solution for mutual exclusion?
Linear-time algorithm for computing the strong component : On the basis of a linear-time algorithm for computing the strong component containing a given vertex v, describe a simple quadratic-time algorithm for computing the strong components of a digraph.

Reviews

Write a Review

Python Programming Questions & Answers

  Fill in the python code

Fill in the Python code to play Tic Tac Toe. I won't award points unless it runs succesfully. # Tic-Tac-Toe Game def drawBoard(board): # Draws the board using the list of numbers print(" ") print(" ",board[0]," | ",board[1]," | ", board[2]) print("--..

  Write a program for checking a circle

Write a program for checking a circle program must either print "is a circle: YES" or "is a circle: NO", appropriately.

  Cleint software so that it does not display

Rewrite the cleint software so that it does not display an echo of a message sent by the users. Maybe it means that each time a user tries to send a private message that same message is also sent back to them? summary: stop that from happening?

  Let ll be a list of integers

Let LL be a list of integers. Use list comprehension to produce teh following lists. Each one should just take onel line. Anser questions as two comments.

  Permutation ciphers

Permutation Ciphers (a.k.a. Transposition Ciphers) are another class of simple cryptosystems. For this we use the functions apply(.,.) and inv(.) from Homework 4; copy these two functions into your le as auxiliary functions.

  The program is to print the time

The program is to print the time in seconds that the iterative version takes, the time in seconds that the recursive version takes, and the difference between the times.

  A string is valid windows filename.

writing a function in python that verifies whether a string is valid windows filename.

  Improve the readability and structural design of the code

Improve the readability and structural design of the code by improving the function names, variables, and loops, as well as whitespace. Move functions close to related functions or blocks of code related to your organised code.

  Create a simple and responsive gui

Please use primarily PHP or Python to solve the exercise and create a simple and responsive GUI, using HTML, CSS and JavaScript.Do not use a database.

  Most popular name would be the one with the biggest number

the program will ask you to insert the year that the user is interested in, then ask the gender that the user is interested in, and print out the most popular names corresponding to the year and gender. FYI, the number on the right represents how man..

  Data file is a comma separated

The data file is a comma separated text values stored in a file with '.CSV' extension. The file has five columns corresponding to employee data fields listed above.

  Write a function trans(m) which returns the transpose

Write a function trans(M) which returns the transpose of an n-by-n matrix M. The matrix M is represented by a list of n lists, each of length n. Transposing M means that each M[i][j] is swapped (once!) with M[j][i].

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