Tuesday, March 10, 2020

Switch Statement in Ruby

How to Use the Case/Switch Statement in Ruby In most computer languages, the case or conditional (also known as  switch) statement compares the value of a variable with that of several constants or literals and executes the first path with a matching case. In Ruby, its a bit more flexible (and powerful). Instead of a simple equality test being performed, the case equality operator is used, opening the door to many new uses. There are some differences from other languages though. In C, a switch statement is a kind of replacement for a series of if and goto statements. The cases are technically labels, and the switch statement will go to the matching label. This exhibits a behavior called fallthrough, as the execution doesnt stop when it reaches another label. This is usually avoided using a break statement, but fallthrough is sometimes intentional. The case statement in Ruby, on the other hand, can be seen as a shorthand for a series of if statements. There is no fallthrough, only the first matching case will be executed. The Basic Form of a Case Statement The basic form of a case statement is as follows. As you can see, this is structured something like an if/else if/else conditional statement. The name (which well call the value), in this case inputted from the keyboard, is compared to each of the cases from the when clauses (i.e.  cases), and the first when block with a matching case will be executed. If none of them match, the else block will be executed. Whats interesting here is how the value is compared to each of the cases. As mentioned above, in C, and other C-like languages, a simple value comparison is used. In Ruby, the case equality operator is used. Remember that the type of the left-hand side of a case equality operator is important, and the cases are always the left-hand side. So, for each when clause, Ruby will evaluate case value until it finds a match. If we were to input Bob, Ruby would first evaluate Alice Bob, which would be false since String# is defined as the comparison of the strings. Next, /[qrz]./i Bob would be executed, which is false since Bob doesnt begin with Q, R or Z. Since none of the cases matched, Ruby will then execute the else clause. How the Type Comes Into Play A common use of the case statement is to determine the type of value and do something different depending on its type. Though this breaks Rubys customary duck typing, its sometimes necessary to get things done. This works by using the Class# (technically, the Module#) operator, which tests if the right-hand side is_a? left-hand side. The syntax is simple and elegant: Another Possible Form If the value is omitted, the case statement works a bit differently: it works almost exactly like an if/else if/else statement. The advantages of using the case statement over an ​if statement, in this case, are merely cosmetic. A More Compact Syntax There are times when there are a large number of small when clauses. Such a case statement easily grows too large to fit on the screen. When this is the case (no pun intended), you can use the then keyword to put the body of the when clause on the same line. While this makes for some very dense code, as long as each when clause is very similar, it actually becomes more readable. When you should use single-line and multi-line when clauses are up to you, its a matter of style. However, mixing the two is not recommended - a case statement should follow a pattern to be as readable as possible. Case Assignment Like if statements, case statements evaluate to the last statement in the when clause. In other words, they can be used in assignments to provide a kind of table. However, dont forget that case statements are much more powerful than simple array or hash lookups. Such a table doesnt necessarily need to use literals in the when clauses. If there is no matching when clause and no else clause, then the case statement will evaluate to nil.

Sunday, February 23, 2020

The moral, ethical and legal issues affecting modern e-business Essay

The moral, ethical and legal issues affecting modern e-business organisations - Essay Example In 2009 UK recorded 18.3 million internet users, accounting for the 70% of country’s total population, which â€Å"is an increase of just under 2 million households (11 per cent) over the last year and 4 million households (28 per cent) since 2006† (National Statistics, Internet Access, 2009). This scenario comprise of a number of different players that range from technological innovations, multinational companies, public policies, legal issues, and ethical values, present a number of challenging constraints and opportunities. Maintaining certain ethical and moral values within any form of commercial enterprise (including modern e-business organisations) are important for attaining sustainable success for that firm. Recently it has become especially important for the business firms, especially those involved in e-commerce, to maintain correct ethical and moral behavioural attitudes to avoid legal problems. In this era of economic globalization and technological convergence there is an emergence of a new form of internet-based society often referred to as the knowledge society, and has raised questions on issues related to various ethical, moral and legal matters. The modern computer based technologies, used for collecting, amassing, managing, and communicating data, though managed to bring in new reforms in the dispersion and application of information, also brought in various ethical and legal dilemmas. The various business firms that operate within this arena face difficulties in the context of right to information, right to privacy, right to the freedom of expression, and intellectual property rights, which vary from country to country. The immense importance and efficiency of internet based systems that include worldwide and local system networks, databases, and the various programs for data processing make it compulsory that policymakers make a review of the existing rights and r esponsibilities, in relation to conducting e-businesses in a legal and ethical manner. (Lynch, Ethical Issues in Electronic Information Systems, 1994). Discussion What is e-business and e-commerce? In the recent times it has been observed that â€Å"The capabilities and opportunities provided by the Internet have transformed many legitimate business activities, augmenting the speed, ease, and range with which transactions can be conducted while also lowering many of the costs†( Williams, 2002, 1). The increase in e-business transactions is evident in the figures presented in the UK National Statistics survey report, â€Å"The value of Internet sales by businesses rose to ?71.1 billion in 2004, an increase of 81 per cent [from] 2003... The results of the 2004 survey show growth in the use of Information and Communication Technologies (ICTs) and large increases in the value of trade over the Internet. The results also highlight significantly greater use of ICTs by the largest businesses (those with 1000 or more employees)... Internet purchases by businesses rose 64.6 per cent from ?37.9 billion in 2003 to ?62.4 billion in 2004† (National Statistics, News Release, 2005). Though computer and data processing systems were present during the 70s and 80s, it was primarily the late nineties that saw a rise in e-trade, where the Internet changed the way many business activities were conducted through speed augmentation, â€Å"ease, and range with which transactions can be conducted while also lowering many of the costs†(Williams, 2002, 1). Thus, the changing perspectives of trading community from that of an actual ‘

Thursday, February 6, 2020

In A Theory of Justice, John Rawls Essay Example | Topics and Well Written Essays - 1500 words

In A Theory of Justice, John Rawls - Essay Example ..no one knows his place in society, his class position or social status; nor does he know his fortune in the distribution of natural assets and abilities, his intelligence and strength, and the like† (Rawls, p. 118). The individual is then tasked with designing a society with this understanding in mind. As a means of carrying out Rawl’s veil of ignorance, this essay proposes what sorts of principles I would propose for this new society. Additionally, the essay considers what guarantees people would have, and what values would be most important to create and preserve. After considering the veil of ignorance one of the overarching considerations of this new society is the need to ensure that it offers fair opportunities to all citizens. As a means of achieving this society there necessarily must be a radical reimagining of the way that the country is structured. Currently society is organized a capitalist democratic model. In this way the primary means of achieving income are through capitalizing on one’s strengths to as great a degree as possible. The pervading logic in this approach to life is that individuals who work the hardest will correspondingly be given the most opportunities and success. There is the further belief that innovation and entrepreneurship will not occur unless people are given a direct financial incentive. While from a theoretical perspective this view of the world may be accurate, in practice there is a great amount of complication. What often occurs is that specific groups of people gain power and are able to oppress other groups of people. In this way survival of the fittest partially takes over, wherein the strong dominate the weak. Additionally, people become oppressed along racial and ethnic lines. In this way many of the brightest and most talented individuals in society are not granted the equal opportunities. Even as society is democratic in nature, the pervading structures are such that these processes are cyc lical, with individuals in power contributing to the oppressive mechanisms. Following the understanding of society as greatly contributing to the oppression of certain groups of people significant changes will be implemented. One of the first changes is that the past notion that all individuals work for the simple accumulation of wealth will be disregarded. Numerous studies have indicated that once an individual makes over $75,000 a year their relative happiness level does not increase. Still, a significant amount of people in society make considerably more than this amount, while millions of others struggle to achieve a living income. The obvious solution is to institute wealth distribution systems, where the wealthiest Americans necessarily distribute their wealth to those making the least amount of money. While such processes are in place to a small extent, the large-scale implementation of these processes have not occurred as there is the general belief that individuals would no t work as hard if they did not receive direct compensation for their actions. Although there is an extent of truth to these claims, ultimately it appears that they do not fully take into account the motivations of human behavior. One considers that individuals such as Warren Buffet have made extensive amounts of money and ultimately given it away to charity. The current Presidential candidate Mitt Romney,

Tuesday, January 28, 2020

Role for bioremediation Essay Example for Free

Role for bioremediation Essay Chapter 1 Which one of the following is not a role for bioremediation? Curing infectious diseases All of the following are examples of new emerging infectious diseases except Chickenpox Normal microbiota: Beneficial microbial inhabitants of the body Golden Age of Microbiology: Rapid discovery of basic microbiology principles Re-emerging diseases: Once controlled by preventative public health measures they are now on the rise Prions: Resistant to the usual sterilization procedures for pathogens Spontaneous generation: The converse of biogenesis Acellular infectious agent: Chemical composition includes RNA or DNA In the scientific name Bacillus anthracis, the term Bacillus is the genus name include the agents responsible for stomach ulcers and plague: Bacteria are prokaryotes: Bacteria impart distinctive flavors in foods such as yogurt and cheese: Bacteria are obligate intracellular parasites: Viruses have a protein coat that surrounds the genetic information: Viruses include molds and yeasts: Fungi contain the protozoa and algae: Protists derive their energy from degrading organic materials: Fungi are the most metabolically diverse group: Bacteria Which one of the following sequences exhibits increasing size? Viruses to bacteria to protozoa Which one of the following would be consistent with the idea of spontaneous generation? Sick people give rise to microorganisms in their body Chapter 3 The gram stain technique is valuable in distinguishing: different types of bacteria One of the below is wrong permit eukaryotic motility: Flagella are involved in group translocation: Chromosomes Contain components of the electron transport chain for ATP generation: Plasma Membranes may have peritrichous or polar arrangements: Flagella are linear rods contained within a nucleus: Chromosomes replication is followed by binary fission: Chromosomes are closed circular single molecues: Chromosomes are used for chemotaxis: Flagella involved with signal sequences in secretion: Plasma Membranes Nucleoid: Stores essential genetic information Glycocalyx: Prevents phagocytosis; attachment Plasmid: Contains a few genes; not essential for cell -Metachromatic granules: Site of nutrient accumulation in cell Fimbriae: Short straight hair-like fibers -Gram (-) cell wall: Rigid outer boundary A bacterial arrangement called a sarcina has which of the following morphological shapes? Spheres in packets of eight All of the following characteristics apply to the prokaryotes except they reproduce by mitosis Chapter 4 A differential medium is one that  distinguishes colonies of one type of bacterium from those of another type Which of the following conditions are most likely to affect the growth of bacteria? temperature, oxygen, and pH At what point in the bacterial growth curve are bacteria the most vulnerable to antibiotics log phase Which of the following methods of measuring population growth is a direct count standard plate count using a dilution series Faculative bacteria are those that  grow in the presence of absence of oxygen Most of the human pathogens are: mesophiles  10. 0001 out of 11 points Mesophiles: this group has most of the the pathogens as they grow at body temperature Halophile: would grow on selective media containing relatively high levels of salt Alkaphile: they can tolerate a pH above 8.5 Psychrotroph: can be found growing in the human stomach Anaerobe: they do not or cannot use oxygen Hyperthermophile: these have been found in seawater from hot water volcanic vents Microaerophile: they survive in environments where O2 concentration is relatively low but are inhibited by high O2 levels Obligate aerobe: this group requires oxygen for metabolism, just like humans Acidophile: can be found growing in the human stomach Facultative Anaerobe: they grow best in the presence of oxygen but can grow in the absence of oxygen Barophile: they are able to live at the bottom of the ocean -The interval of time between successive binary fissions of a cell or population of cells is known as the: generation time -Psychrophiles and thermophiles differ with respect to their best temperature for growth A soil sample is added to a culture medium that has been designed to promote the growth of the genus Pseudomonas while inhibiting the growth of fungi. This test uses a: selective medium Chapter 5 Low temperature is:  bacteriostatic Heavy metals generally kill microorganisms by  reacting with protein sulfhydryl groups to disrupt function Chlorhexidine is a biguanide used to  wash hands and clean wounds superficially The chemical counterpart of the autoclave uses  ethylene oxide with an inert gas HEPA filters are used to filter which one of the following? Air Ultraviolet light is valuable for reducing the microbial population in the air of a hospital room Of the following, the most efficient method for sterilization of a bacteriological transfer loop is the direct flame Triclosan destroys bacteria by  disrupting cell membranes Which one of the following elements would be classified as a halogen Chlorine Moist heat kills microorganisms by  denaturation A substance that has been pasteurized  is not considered sterile 5 out of 8 points Autoclave: Vegetative microorganisms, and endospores Direct Flame: Vegetative microorganisms, and endospores Boiling water for 10 minutes: Vegetative microorganisms, not endospores Hot air oven for 2 hours at 160 degrees Celcius: Vegetative microorganisms, and endospores Pasteurization: Pathogenic microorganisms, not endospores Gamma radiation: Vegetative microorganisms, not endospores Filtration: Pathogenic microorganisms, not endospores Ultra-high-temperature (UHT) processing: Vegetative microorganisms, not endospores When food has been salted  water diffuses out of microorganisms causing them to shrivel Chapter 6 The Krebs cycle accounts for all the following except  production of pyruvate from glucose Heat is useful in the destruction of bacteria because heat denatures enzymes by altering their tertiary structures 10.99956 out of 13 points yields pyruvate for use in the TCA cycle: Glycolysis requires cytochromes for electron transport: Oxidative phosphorylation requires electrons eventually be passed to NADPH: Photosynthesis Requires energy from light to take place: Photosynthesis ends with acceptance of electrons by oxygen atoms: Oxidative phosphorylation starts with the oxidation of NADH: TCA Cycle requires an investment of 2 ATPs: Glycolysis uses chlorophyll as the pigment in the cyanobacteria: Photosynthesis results in the formation of water: Photosynthesis is essentially the opposite of aerobic respiration: Photosynthesis begins with a glucose molecule: Glycolysis results in the net gain of 2 ATPs: Glycolysis generates two carbon dioxide molecules per turn: TCA Cycle Which one of the following does not involve a phosphorylation reaction? The hydrolysis of ATP Which of the following states is the most correct for enzyme reactions Enzymes are specific for only one reaction, generally in one direction All of the following apply to the process of anabolism except the process is exergonic You are studying an obligate anaerobe. Which one of the following pathways can you be assured is occurring? Glycolysis A bacterium that uses glucose as an energy source has been isolated from an anaerobic environment. After the growth of the bacterium, the pH of the growth medium is measured and found to be very acidic. When analyzed, the medium is found to have a high concentration of lactic acid. This bacterium is most likely metabolizing by a process known as fermentation

Monday, January 20, 2020

Computers In Education :: essays research papers

Computers in Education The typical school has 1 computer per 20 students, a ratio that computer educators feel is still not high enough to affect classroom learning as much as books and classroom conversation. Some critics see computer education as merely the latest in a series of unsuccessful attempts to revolutionise education through the use of audio- and visually-oriented non print media. For example, motion pictures, broadcast television, filmstrips, audio recorders, and videotapes were all initially heralded for their instructional potential, but each of these ultimately became minor classroom tools alongside conventional methods. Communications Satellite A communications satellite is an artificial SATELLITE placed into orbit around the Earth to facilitate communications on Earth. Most long-distance radio communication across land is sent via MICROWAVE relay towers. In effect, a satellite serves as a tall microwave tower to permit direct transmission between stations, but it can interconnect any number of stations that are included within the antenna beams of the satellite rather than simply the two ends of the microwave link. Computer Crime Computer crime is defined as any crime involving a computer accomplished through the use or knowledge of computer technology. Computers are objects of crime when they or their contents are damaged, as when terrorists attack computer centres with explosives or gasoline, or when a "computer virus" a program capable of altering or erasing computer memory is introduced into a computer system. Personal Computer A personal computer is a computer that is based on a microprocessor, a small semiconductor chip that performs the operations of a c.p.u. Personal computers are single-user machines, whereas larger computers generally have multiple users. Personal computers have many uses such as: Word processing, communicating to other computers over a phone line using a modem,databases,leisure games are just some of the uses of a Personal Computer. Computers for Leisure Games As they proliferated, video games gained colour and complexity and adopted the basic theme that most of them still exhibit: the violent annihilation of an enemy by means of one's skill at moving a lever or pushing a button. Many of the games played on home computers are more or less identical with those in video arcades. Increasingly, however, computer games are becoming more sophisticated, more difficult, and no longer dependent on elapsed time a few computer games go on for many hours.

Sunday, January 12, 2020

Kantian Ethics Essay

Immanuel Kant’s moral theory has become the heart of deontological ethics. It differentiates itself by looking at morality as an extension of man’s reason. Unlike other ethical theories, the individual is seen as the primary actor of all moral decisions. His autonomy, his will is seen as the locust of ethical judgment. For Kant in order for an act to be considered morally worthy it has to be done out of duty. From my understanding of Kant, when we talk of duty it is something which our reason recognizes as a manifestation of a universal law, one which he/she cannot deny. Doing the right thing is not about whether or not the outcome might be gauged to be positive, or that because an individual â€Å"feels† that he/she must perform a particular act rather she â€Å"knows† that it is his/her duty. In order to be ethically praiseworthy, the person must ask himself, â€Å"Am â€Å"I† the one who is deciding and acting? † The morality of Kant builds on the want of the philosopher to describe and order an ethical life that is centered on the rational faculty of man, his reason. It is the case that in a lot of cases people tend to look at the possible consequences of an action in judging whether or not what they’re about to do is moral or not. At times we act out of good intentions, helping others, sharing, et al. because we feel that it’s the good thing to do. Unfortunately, Kant won’t agree with our ways. In fact, he would even say that such actions have no moral worth. For Kant, the important thing is our obligation to do something, feelings, intentions, and consequences may gain the approval of others but they are too whimsical. There is for him an a priori (before reason) law which tells us what ought to be done. As rational beings we are dignified with our ability to discern this law, much more, we are capable of making it (Kremling, n. d. ). To act contrary to what our reason dictates, is choosing to act in heteronomy, a big no-no for Immanuel Kant because it belittles the individual, the latter produces as a result, acts that are empty. If Kantian Morality sounds a bit of feel-good emotions, intentions, and happy thoughts, then I think we’re on the right track. Ethics in terms of Kant is not about making another person smile; it’s not about calculating how many people you could help out by doing something. At the end of the day, acting on such things are all half-chances, there is no guarantee that by helping someone out would be good, there’s no assurance that if you think of the number of people who would benefit, it means you won’t harm others. Autonomy plays a central role in the moral theory of Kant, in such a way that a man must in his own volition choose to legislate a universal law and act in accordance to it. How does one determine which acts are in accordance with good will per se and is thus uninversalizable? For Kant all actions can be stated as a maxim, a person as an autonomous person creates the maxim but at the same time has to make sure that it is a principle that every rational being can agree to with no exceptions. This is the categorical imperative, contrary to the hypothetical imperative which is stated as an If-then. I. e. If I want to pass this class then I have to study; the Categorical Imperative claims a universal statement that is true at all times (. When a person acts out of duty the latter is presumed to have passed the categorical maxim put forward to state the action: In layman’s terms we could state the maxim as a question first, i. e. can I will to cheat on an exam, in such a way that others would as a whole can will to do so? There are categorical imperatives that have been formulated by Kant as the most basic of ethical requirements, like for example, Lying is an act that for him will never become morally justifiable, we must always follow the imperative to never use a person but always as an end (Hillar, 2003). We again see here the theme of dignity and respect, man and his reason is central in the ethical works of Kant. Even if for example in doing an act we would do so for the good of the majority, it would still not be valid if a minority would be sacrificed along the way. We do something because it ought to be done as determined by our reason and verified through the maxim which we test and attempt to put as a categorical imperative; the latter could be thought of as the fixed rules that govern how we as rational agents act. The main criticisms to be raised with regards to other ethical theories are founded on the assumptions of Kant regarding the fulfillment of moral obligation for the sake of good in itself. Utilitarianism takes as a central part of its tenets, the concept of summum bonum (greatest good for the greatest number). If we look at this ethical formulation we shall see that it would contradict with the notion of Kant that Human Being should always be considered ends never as a means, not even for the greatest number. Problem may also arise in the altruistic claims of utilitarian moralizing. One ought not to pursue something out of happiness or other virtues like Aristotle’s notion of the good man as the man of mean and virtues. This would not qualify for Kant as enough grounds to pursue good, because as he had mentioned in the groundings, prior to the good is the good will with which there is no qualification (Johnson, 2004). If one is an individualist, he might more likely be pleased with the ethical prescriptions of Kant. I personally find strength in his moral philosophy in finding support for the need to protect certain inalienable rights. In focusing on a moral law, his theory is not vulnerable to the attacks of situational morality but rather focuses on the man as a rational being and a moral agent, whose will is in a sense the will of all (Baron, 1995). There is stability and consistency in Kant’s moral philosophy by centering on the autonomy of all individuals under the precept that when it all boils down to it, man shares a common reason and will that would allow them to determine what is right from wrong. On the other hand I think that there are certain things in life wherein following the rules set through categorical imperatives would not suffice. There are moral dilemmas wherein human lives are hanged in the balance. Although reason can help us in making our decisions, the moral duties of Kant can only go so far. I am left to wonder how a person could be satisfied with himself in pointing the whereabouts of innocent African-Americans to deranged members of the Ku Klux Clan who are vowing to kill them; on the basis of fulfilling his moral duty of always telling the truth. Take note, in Kant’s philosophy, there is no hierarchy of duties, one has to fulfill them all, regardless of the outcome. References: Baron, Marcia, 1995, Kantian Ethics Almost Without Apology Cornell: Cornell U. P. Hillar, Marian, 2003, Kant’s Moral Axioms, Retrieved August 3, 2007 from Socinian. org: http://www. socinian. org/kant. html Johnson, Robert, 2004, Kant’s Moral Philosophy, Retrieved August 4, 2007 from Stanford http://plato.stanford.edu/entries/kant-moral/

Saturday, January 4, 2020

Crime And The Criminal Justice System - 1561 Words

Introduction: Over the past 30 years, crime has become a major issue of public concern, of political discussion and action, often intemperate and not likely to reduce crime, and of major public expenditure. Despite its salience in public arena, very little is known about the factors driving the crime trend, and the knowledge base is too limited to support intelligent forecasts of the direction in which crime rates are moving, especially when changing direction. Developing such as knowledge base is important for enhancing the rationality of public policies and public expenditures related to crime, particularly because many such commitments have to be made well in advance of†¦show more content†¦Some of these factors could be addressed in the context of generating policies intended to reduce crime. For example, to the extent that unemployment among teenagers and young adults is a major contributing factor to the crimes they commit, then efforts at providing job assistance, job training, or extending unemployment support for those groups could well be stimulated by their anticipated crime trends. Crimes: Crimes are defined by criminal law, which refers to a body of federal and state rules that prohibit behavior the government deems harmful to society. If one engages in such behavior, they may be guilty of a crime and prosecuted in criminal court Types: Personal Crime: Offenses against the Person†: These are crimes that result in physical or mental harm to another person. Personal crimes include: †¢ Assault †¢ Battery †¢ False Imprisonment †¢ Kidnapping †¢ Homicide – crimes such as first and second degree, murder, and involuntary manslaughter, and vehicular homicide †¢ Rape, statutory rape, sexual assault and other offenses of a sexual nature Property Crime: â€Å"Offenses against Property†: These are crimes that do not necessarily involve harm to another person. Instead, they involve an interference with another person’s right to use or enjoy their property. Property crimes include: †¢ Larceny (theft) †¢ Robbery (theft by force) – Note: this is also considered a personal crime since it results