Website for the College study materials and cheats you can use

Translate

Showing posts with label College Study. Show all posts
Showing posts with label College Study. Show all posts

Defining and explaining Syntax of a programming language, Differences between syntax errors and semantics errors

Defining and explaining the Syntax of a programming language

A program in computer science is a sequence of instructions that a computer can execute (Eck, D.J. 2019 pg 34). This sequence of instructions needs to be written in programming languages (formal languages established by humans) before the computer can understand them and make execution. The reason is that human language (natural language) really differs from computer language in the sense that computer language is very strict, unambiguous (Eck, D. J. 2019 pg 34), they are not literal meaning that they mean exactly what they say: a correct input gives correct output but an error input gives an error output ( Downey.A. 2015 pg27) whereas human language is the opposite of the computer language characteristics. So with all these being said, the syntax of a language are the rules that determine how a program should be constructed in that specific language since every formal language has its own syntax.


Defining and explaining Semantics of a programming language

Semantics are referred to as the meaning of a written program. Elaborately a programming language semantics is the set of rules that determine the meaning of a program in a specific language ( Eck, D.J. 2019 pg 35).


Differences between syntax errors and semantics errors.

First, let us define what these two errors mean when they occur in programming in so doing we can easily grab the differences between them.


A syntax error is an error in a program that makes it impossible for the interpreter to interpret (Downey 2015 pg 37). This usually occurs when we do not respect the syntax of the programming language we are utilizing. And since formal languages are not literal, meaning that they mean exactly they say, the input we put is the output we get (Downey.A. 2015 pg 27).


A semantic error is an error in a program that makes the program do the opposite of what the programmer intended the program to do (Downey.A. 2015 pg 37). or causes the program to run incorrectly (Eck. Dj 2019 pg 74). Some semantic errors occur when a variable is not properly initialized. (when another variable type is used to initialize another variable type).


With each definition, we can clearly see the difference between these two types of programming errors. In a nutshell, a Syntax error has to do with the syntactic error of the programming language we are using and Semantic error has to do with the error occurred in the meaning of what the programmer wants the program to produce.


Example of Syntax error:

public class syntaxandsemanticerror {

public static void main(String[] args) {

/* This program will produce a syntax error because i missed putting the variable

* "principle" near the if conditional in parenthesis */

int principle;

principle = 87;

Double interest;


if principle > 98

interest = principle * 0.02;

else

interest = principle *2.1;

System.out.println(interest);


Example of Semantic errors:

// Semantic error

/* This will output a semantic error because i used a type variable for another variable type on number2*/

int number;

int calculate;

int number2;

number = 43;

number2 = 32.32;

calculate = number + number2;



// Second semantic error


/* I want (the programmer) the program to print in a new line but it will do something different

* This is because i used "print" instead of "println*/

String name;

name = "Israel";

System.out.print("Welcome, " + name + " Pleased to meet you");


// Note that this program won't be able to run due to the syntax and semantic errors it contains to run it try removing the errors

}

}


Please find below an attached file of the program.


REFERENCES:

Eck, D. J. (2019).Introduction to programming using Java, version 8.1. retrieved from http://math.hws.edu/javanotes.

Downey, A.(2015). Think python, How to think like a computer science

DISCUSSION UNIT 1 Introduction to Programming

PROGRAMMING 1

                                                                                                                            CHICK ETIEN NDEH

                                                                                                                   University of the People

DISCUSSION UNIT 1

Introduction to Programming



Briefly explain what is meant by the syntax and the semantics of a programming language. Give an example to illustrate the difference between a syntax error and a semantics error.



Any syntax of a programing language shows its grammar, and the semantics is its meaning. A program with a syntax error cannot be compiled reason been that during the code an error courses the program not to give any output.

while a program with a semantic error can be compiled and run but gives an incorrect result. In this case, the code will run smoothly but will give a different meaning rather than the output expected.

According to (Arnab S IITian, JavaHolic, Raconteur 2017 ) Syntax errors occur during the parsing of input code and are caused by grammatically incorrect statements. Typical errors might be an illegal character in the input, a missing operator, two operators in a row, two statements on the same line with no intervening semicolon, unbalanced parentheses, a misplaced reserved word, etc.


Semantic errors occur during the execution of the code after it has been parsed as grammatically correct. These have to do not with how statements are constructed, but with what they mean. Such things as incorrect variable types or sizes, nonexistent variables, subscripts out of range, and the like, are semantic errors.


 A missing semicolon in a program is an example of a syntax error because the compiler will find the error and report it. If N is an integer variable, then the statement "frac = 1/N;" is probably an error of semantics. The value of 1/N will be 0 for any N greater than 1. It's likely that the programmer meant to say 1.0/N.



Splitting a string over two lines: In most cases, Java doesn’t care if your code appears on one or more lines. However, if you split a string across lines so that the string contains a newline character, then the compiler will object.

The answer is to end the string on the first line with a double quote, add a plus sign to tell the compiler you want to concatenate (add) this string with another string, and then continue the string on the next line like this (John P. M  Java eLearning Kit For Dummies April 2014.p01, para 2)


      System.out.print("This is a really long " +
            "string that appears on two lines.");
Semantic errors

Use of a non-initialized variable:

int i;

i++; // the variable i is not initialized

 Errors in expressions:

String s = "...";

int a = 5 - s; // the - operator does not support arguments of type String


References

John P. M  Java eLearning Kit For Dummies April 2014.p01,para 2 retrieved from https://www.dummies.com/programming/java/syntactical-errors-in-java/
Arnab S IITian, JavaHolic, Raconteur 2017 retrieved from https://www.quora.com/What-are-the-differences-between-syntax-errors-and-semantic-errors

Universal Declaration of Human Rights is a document that was written for all nations

Universal Declaration of Human Rights
Unit 3
University of the People


Universal Declaration of Human Rights is a document that was written for all nations, a kind of guideline for everyone regardless of age, nationality, race, gender. This document highlights freedom and equality for all. It encourages all nations to follow this declaration. (Levin Institute, (n.d.) 2019). Over time these rights have improved the rights of many, one example of this is now over 198 counties allow women to vote (Declaration of Human, (n.d.)2018).

First of all, I feel that all the articles are important. I feel that life experience could make you look at the articles in different ways. So, at this time these are important to me. The 3 articles that I chose are Article 2, Article 5, Article 11 (Human Rights (n.d.), 1989). Article 2 Freedom of Discrimination. I justify this by my own experiences. I have been discriminated against in several different ways. It has changed my life in ways I can’t even explain. These experiences changed my life and it had a lasting impact on me. Next, I chose Article 5 Freedom from Torture and Degrading Treatment. I justify this because torture is ramped around the world, in some places, it’s getting worse. In an article in USA Today (2017) it brought out that sexual abuse of women has worsened, along with extrajudicial killing increased in the Philippines. There’s a similar problem in China with unlawful deprivation of life, executions, and torture. So, this is the reason I feel Article 5 is important. Article 21 Right to Participate in Government and in Free Elections. In America we have the freedom of choice, we can vote to let our opinion be heard. It’s important to be able to have a part in changing policy, in turn, it’s a start to changing the world.

The case study I’m going to talk about is The Case Against Human Rights (Posner E. 2014) There was a bricklayer who lived in Rio De Janeiro. Police suspected him of drug trafficking. He was arrested then disappeared. No one ever saw him again. This caused outrage with the citizens. There was an investigation that leads to the arrest of 10 police officers who were charged with torturing and murdering this poor man. You would think that because Brazil is
one of the largest democracies in the world, they wouldn’t have this problem. More than 1000 killings happened by police in Rio De Janeiro in one year. They say most likely all deaths to were executions. These types of atrocities are happing all over the world, South Africa, Dominican, Republic, and Iran to name a few (Posner E. 2014). So, I feel that this supports the Articles I have chosen discrimination, freedom from torture, and voting because this is still happening, and we have a voice to help stop it.

This is why the declaration of human rights is so important. No matter which Article we chose every single one of them is important. We all see the world in a different way, and I feel that’s why many articles cover a little of all the issues around the world.




Reference

Levin Institute, (n.d.), (2019) Human Rights
https://my.uopeople.edu/pluginfile.php/770765/mod_book/chapter/229104/glob101humanrights.pdf


How has the declaration of human rights changed, n.d.(2018) Peace news.,
https://www.peacenews.com/single-post/2018/08/11/How-has-the-Declaration-of-Human-
Rights-changed-the-world

Human Right Here and Now (n.d.) (1998)
http://hrlibrary.umn.edu/edumat/hreduseries/hereandnow/Part-5/8_udhr-abbr.htm


USA Today, (2017) U.S. Corruption, torture, discrimination worse in parts of the world. Retrieved from https://www.usatoday.com/story/news/world/2017/03/03/united-states-free-expression-decline-worldwide/98706280/

Posner E. (2014) Case against human rights Retrieved by https://www.google.com/amp/s/amp.theguardian.com/new/2014/dec/4/-sp-case-against-human-rights

The United Nations Millennium Development Goals are eight goals that all 191 UN member states have agreed to try to achieve by the year 2015

The United Nations Millennium Development Goals are eight goals that all 191 UN member states have agreed to try to achieve by the year 2015. The United Nations Millennium Declaration, signed in September 2000 commits world leaders to combat poverty, hunger, disease, illiteracy, environmental degradation, and discrimination against women.
The Eight Millennium Development Goals are:
1. to eradicate extreme poverty and hunger;
2. to achieve universal primary education;
3. to promote gender equality and empower women;
4. to reduce child mortality;
5. to improve maternal health;
6. to combat HIV/AIDS, malaria, and other diseases;
7. to ensure environmental sustainability; and
8. to develop a global partnership for development.

The MDGs have proven that goal-setting can lift millions out of poverty, empower women and girls, improve health and well-being, and provide vast new opportunities for better lives.
The number of people now living in extreme poverty has declined by more than half, falling from 1.9 billion in 1990 to 836 million in 2015.
The primary school net enrolment rate in developing regions has reached 91 percent in 2015, up from 83 percent in 2000.
The developing regions have achieved the target to eliminate gender disparity in primary, secondary, and tertiary education.
Women have gained ground in parliamentary representation in nearly 90 percent of the 174 countries with data over the past 20 years.
The global under-five mortality rate has declined by more than half, dropping from 90 to 43 deaths per 1,000 live births between 1990 and 2015.
Since 1990, the maternal mortality ratio has declined by 45 percent worldwide and most of the reduction occurred since 2000.
New HIV infections fell by approximately 40 percent between 2000 and 2013.
Over 6.2 million malaria deaths were averted between 2000 and 2015.
Between 2000 and 2013, tuberculosis prevention, diagnosis, and treatment interventions saved an estimated 37 million lives.
In 2015, 95 percent of the global population is using an improved drinking water source, compared to 76 percent in 1990. (Millennium Development Goals Report 2015). Considering all the facts mentioned above we can see that significant progress has been made in achieving many of the goals and targets. Some goals were even achieved earlier than it had been planned.
However not all the targets could be reached. For example, still, too many children are denied their right to primary education. The child and maternity mortality ratio decreased, not enough though to meet the target of the MDGs.
Despite progress, women continue to face discrimination in access to work, economic assets, and participation in private and public decision making. Gender parity in education still has a long way to go in some countries. Wide gaps remain in women’s access to paid work in at least half of the developing regions. Gender parity in politics also remains a distant target. A lot of people still live in extreme poverty and suffer from hunger.
I think it is great that so many world leaders support the MDGs and do their best to achieve the goals. However, time goes. Globalization has changed the world. It is no longer the world it used to be in the 2000s. Technology develops so fast that it is difficult sometimes to keep yourself updated. All of it raises new issues and new goals appear. I would definitely add something to stop the conflicts in different regions. It is very political, so I will not mention the countries. But those conflicts are the biggest threat to human development, with fragile and conflict-affected countries typically experiencing the highest poverty rates.
I would put the environmental problem higher on the list. We are destroying the Earth with our actions. Global warming is showing its power. Urgent actions need to take.
With the current events that are connected with the pandemic of COVID-19, we can see that the world needs to be United with stronger ties to support each other in difficult times. Every year a new virus appears Ebola, MERS, Covid-19, etc. The problem of health, fighting all the appearing viruses needs to be one of the tops.

References:
N/A. (n/a). Millennium Development Goals Report 2015. Retrieved from https://www.un.org/millenniumgoals/news.shtml

Millennium Development Goals Unit 2 University of the People

Millennium Development Goals
Unit 2
University of the People

Millennium Development Goals also are known as MDGs, is where the United Nations all agree to try to accomplish goals by 2015. The first goal is to eradicate extreme poverty and hunger. Second to achieve universal primary education. The third is to promote gender equality and empower women. Forth reduce child mortality. The fifth is to improve maternal health. Sixth to combat HIV/AIDS, malaria, and other diseases. Seven to ensure environmental sustainability.
Eight is to develop a global partnership for development. (“Levin Institute (n.d.),” 2019). All of these goals are supposed to be cooperative amongst nations to help better agriculture, trade, and come up with better ways to aid in the health of people around the world.

One goal I believe should be kept in its place, is the goal to eliminate poverty and hunger. I can’t believe we still live in a world where there are people starving. In 2016 there was a study done by the United Nations Food and Agriculture Organization and they showed that 815 million people in the world are starving. 11 million people in the world are undernourished (“World Hunger,” 2018). You would think that with all the advancement we have, we would be further along in being able to feed the hungry. This is unacceptable and this is why I believe it should stay first on the list.

I believe that all the goals are important to keep, but I feel that we need to put a higher importance on child mortality. In this list child, mortality is forth behind gender equality.
I would modify this and make it third. Saving lives to me is one of great importance.
In 2018, 5.3 million children who were under five died from preventative reasons (“Global Health Observatory,”2020) This needs to change.

In conclusion, these goals were to be reached by 2015, but this doesn’t take away from the relevance today. All of the goals from the MDGs still need to be achieved. We need every nation to work together. This way they can find a better way to trade and provide aid in a way to help and benefit the most impoverished people.

Word count 398


Reference

Levin Institute (n.d.), (2019) International monetary fund and world bank
https://my.uopeople.edu/pluginfile.php/770759/mod_book/chapter/229096/glob101imfandwb.pdf

World Hunger and Poverty Facts (n.d.), (2018), retrieved from https://www.worldhunger.org/world-hunger-poverty-facts-and-statistics/

Global Health Observatory, (n.d.), (2020), retrieved from https://www.who.int/gho/child_health/mortality_under_five_text/en/

Various theories on globalization exist. Choose two from the readings and describe each—one you agree with and one you disagree with—briefly describe each theory, and explain your reasons or agreement and disagreement

1. Various theories on globalization exist. Choose two from the readings and describe each—one you agree with and one you disagree with—briefly describe each theory, and explain your reasons or agreement and disagreement.

After reading the different theories, I have decided to write about the World Culture Theory and World-System Theory because both are visible for me, which I can see for myself and have an opinion. When things become personal, our vision changes and we are able to have a better expression and in the two situations, I can say that affects my life directly. The first one is based on the way I live and see the world and it is interesting how different people can think from me, I can see that through my classmates when I give my opinion and they automatically disagree with the argument that the way they live and see things make them think differently. The second one is based on how countries live, at the moment I am in The US but I am from Brazil and I can see how different everything is and how powerful the United States is over Brazil.

"World culture theory seeks to explain an apparent convergence of education through a neoinstitutionalist lens, seeing global rationalization in education as driven by the logic of science and the myth of progress." (Carney, Rappleye & Silova, 2012 p.366). In other words, it is a theoretical framework that seeks to understand and explain the processes of the growing intertwining of communication and exchange relations that are happening worldwide in almost all social, economic, and scientific-technological spheres.

"The world-systems theory is a fundamental unit of analysis for social evolution. Also known as world-systems analysis or the world-systems perspective, it is a multidisciplinary, macroscale approach to world history and social change. It takes up a more inclusive unit of analysis, the “world system,” which reflects a particular understanding of history and a set of questions people pose related to it." ( Christofis, 2019). In other words, it is a post-Marxist theory of international relations, geo-economics, and international political economy that focuses on the study of the social system and its possible interrelations with the advance of world capitalism as determining forces between different countries.

The world-system theory is the one I most agree, because the focus of this theory is the structure and not the agents, it seeks to understand how the capitalist means of production works through a macro and multidisciplinary approach to world history. Based on the international division of labor, the purpose is to explain why there is tremendous inequality between countries. The current world system is similar to the previous ones due to the axial division of labor and functioning in a cyclical and secular way and is differentiated by the infinite accumulation of capital, which is provided by capitalism. On the other hand, there is the world culture theory, which I do not completely disagree with, but the modification of cultural patterns happens in poor countries due to the influence of Northern (rich) countries.

Globalization corresponds to the process of economic and cultural integration on a world scale, promoted by the expansion of informational capitalism and by the technological evolution of the means of communication and transportation. It is in a continuous process of evolution and transformation, enabling greater integration every year, with the innovation of the means of communication and transport. The speed and efficiency achieved by the transport and communication sectors in the last decades with information technology were responsible for the consolidation of the integration/connection process between different parts of the world.


References:
Carney, S., Rappleye, J., & Silova, I. (2012). Between Faith and Science: World Culture Theory and Comparative Education. Comparative Education Review, 56(3), 366-393. DOI:10.1086/665708

Christofis N. (2019) World-Systems Theory. In: Romaniuk S., Thapa M., Marton P. (eds) The Palgrave Encyclopedia of Global Security Studies. Palgrave Macmillan, Cham

Labels

College Study Globalization

Popular Posts

Categories

Contact Form

Name

Email *

Message *