1- CIND830, Module 4 - Introduction
.pdf
keyboard_arrow_up
School
Toronto Metropolitan University *
*We aren’t endorsed by this school
Course
830
Subject
Computer Science
Date
Jan 9, 2024
Type
Pages
4
Uploaded by SargentHyena3676
1/30/22, 5:43 PM
CIND830, Module 4 - Introduction
https://de.ryerson.ca/de_courses/templates/m/?c=70162FE655EC381AC6312EBF026AAC54&m=4&p=200700
1/4
Introduction
In this module, we will cover selection statements, or those statements in Python which help make
choices during the program run-time and select a set of actions based on a specific criterion or based on
the flow of data.
We have two topics to cover in this module: the first is comparison expressions
, also known as
relational and logical expressions
, statements in Python that compare two operands or variables, and
result in either a Boolean or NoneType object. Then we will move to the second topic in which we will
learn the different types of selection statements
. For each type, the syntax and structure will be
covered, and an illustrative example will be provided to help in exploring them in practice.
Topics and Learning Objectives
Topics
Comparison expressions
Types of selection statements
Learning Objectives
By the end of the module, you will be able to:
Relate the third-valued logic to the output of the conditional statements.
Construct a conditional statement to make decisions at run-time.
Differentiate between one-way, two-way, and multi-way statements.
Readings
Required Readings
Lambert, K. A. (2019). Fundamentals of Python: First programs
(2
ed.). Boston, MA:
Cengage Learning.
Loops and Selection Statements, pages 77–85
Comparison Expressions
Please watch and study this video presentation as it demonstrates the implementation of the relational
and logical operators in Python. It also explains the critical differences between the relational and logical
expressions in terms of designated operators and the data type of their respective operands. The
standard Boolean logic used in Python, which includes the True
and False
objects, has been extended
to include a third logical object: None
, which represents the absence of data and interprets the output of
the logical expressions. nd
1/30/22, 5:43 PM
CIND830, Module 4 - Introduction
https://de.ryerson.ca/de_courses/templates/m/?c=70162FE655EC381AC6312EBF026AAC54&m=4&p=200700
2/4
Download
Download the PDF file for CIND830 - Module 4: Selection Statements
.
Please note this PDF file will be used in the two videos of this module. In the PDF, you can use the
top navigation bar to navigate between the topics covered in each video.
Download the CIND830 - Module 4: Comparison Expressions transcript
.
Types of Selection Statements
Please watch and study this video presentation. It explains how the Python interpreter selects specific
statements or actions, and makes choices during run-time, or as data flow in the program. Three types
of selection statements will be explored: one-way
, two-way
, and multi-way selection statements. For
each type, an illustrative example is provided to show the selection statement's syntactic structure and
describe the boundaries of the statement at run-time.
Download
Download the PDF file for CIND830 - Module 4: Selection Statements and click on the topic
“
Types of Selection Statements
” in the top navigation bar to take you to the beginning of this topic.
Download the CIND830 - Module 4: Types of Selection Statements transcript
.
Self-Assessment Quiz
Please complete the following review activity. The activity is not graded.
Test Yourself
Summary
In this module, we covered the comparison expressions that include relational and logical expressions.
We highlighted the key differences between them and introduced the three-valued logic that Python
Ryecast Video:
CIND830 - Module 4: Comparison Expressions
Ryecast Video:
CIND830 - Module 4: Types of Selection Statements
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
- Access to all documents
- Unlimited textbook solutions
- 24/7 expert homework help
Related Questions
C++ Programming
arrow_forward
Requirements for Your M5 Assignment 1 Pseudocode for Program Integration
For the first module, write the pseudocode to process these tasks:(Note: lines beginning with # are comments with tips for you)
From the random module import randint to roll each die randomly
# in pseudocode, import a random function
# the name is helpful for the next M5-2 assignment
Define a class called Dice
In Python, the syntax has a colon after it: class Dice():
In pseudocode, you can specify it generally or be specific
Under the class declaration, list the attributes. Here are some tips:
# attributes are what we know about a single die (dice is plural)
# self is the first attribute in Python and must always appear first
# add a num_sides attribute and to set it to 6 for the 6 sides on the dice
Define a method for roll(self)
# it describes what happens when we roll a single die
# in the code, it will look like this example
def __init__(self, dice_sides=6):
# in pseudocode, we do not worry about…
arrow_forward
Dijkstra's algorithm Weight Class Implementationlanguage : C++
Note : Skelton Files Provided
Please check the linksproject Details:https://ece.uwaterloo.ca/~dwharder/aads/Projects/5/Dijkstra/
Files:https://ece.uwaterloo.ca/~dwharder/aads/Projects/5/Dijkstra/src/
Please provide clear and complete solution for thumps up.
arrow_forward
Art.java
In this part you will create a program Art.java that produces a recursive drawing of the design attached in the picture.
Requirements
Art.java must take one (1) integer command-line argument n that controls the depth of recursion.
Your drawing must stay within the drawing window when n is between 1 and 7. (The autograder will not test values of n outside of this range.)
You may not change the size of the drawing window (but you may change the scale). Do not add sound.
Your drawing can be a geometric pattern, a random construction, or anything else that takes advantage of recursive functions.
Optionally, you may use the Transform2D library you implemented in Part 1. You may also define additional geometric transforms in Art.java, such as sheer, reflect across the x- or y- axis, or rotate about an arbitrary point (as opposed to the origin).
Your program must be organized into at least three separate functions, including main(). All functions except main() must be private.
call…
arrow_forward
link - https://docs.python.org/3/library/time.html for time module
Code -
def long_running_task(n):
num = 0
for x in range(n):
for y in range(n):
for z in range(n):
num += x + y + z
return num
print(long_running_task(500))
arrow_forward
Instructions: In Basic C Language
In the code editor, you are provided with a main function that asks the user for an integer input and passes this value to a function called, getFactorial()
The getFactorial() function has the following description:
Return type - int
Name - getFactorial
Parameters - one integer
Description - returns the factorial of the passed integer
Your implementation should be RECURSIVE and you should not use any loops
Input
#include<stdio.h>
int getFactorial(int);
int main(void) { int n; printf("Enter n: "); scanf("%d", &n);
printf("Factorial of %d is %d", n, getFactorial(n));
return 0;}
int getFactorial(int n) { // TODO: Implement this recursive function}
Output should be:
Enter n: 3
Factorial of 3 is 6
arrow_forward
Scenario
You are tasked to write a Python module named after you to help create score cards to students in a class. The following seven subject should show on each student’s score card: Algebra, English, Statistics.
Our program should first ask for a student's name, then her/his scores for the three subjects in the order shown above. This process will be repeated until all the students’ scores are entered. Note that there are four (4) students and their names are the AB, CD, EF, GH.
Use Python ASCII/UTF-8 functions chr and ord to generate the names; do not input the names manually.
(Hint: You might need to use a dictionary and a function to accept all the input.)
Create another function to handle the printing as follows:
When the printing function is called, a single student name is passed to it as an argument. (e.g., function3(AB)), the function then prints the student’s name and his/her scores in two columns, one for the subjects and one for the scores. The subject and the…
arrow_forward
C++ CODE DEBUG FIXING
A rise will be given after giving me an explanation and output screen cut
HERE IS DEBUG NOTE
Dear Andy,
I have withheld an assignment of a grade for two major reasons. The first is that the program does not demonstrate a knowledge of the usage of C++ class. The second is that the use of the compile-time library leads to some usages which are not standard C++ and which caused your program to fail to compile using my standard C++ compiler. I will explain these issues below.
First, the usage of class has two data members specified as public. This is incorrect usage, because all data members in a C++ class must be specified as private. Therefore, access to them in the using program must use get and put methods. For example getSum and putSum, also getCount and putCount. These methods should appear under public. These methods and additional methods are the only way to access the data members of a class. In addition, your program has redefined sum and count as variables…
arrow_forward
Course: Object Oriented programming
Lnaguage: C++
You have to solve the Make the program correctly and in 1 hours.
kindly Make program correct as much as you can.
Dont copy paste from any site or google do something that you can.
please read question completly then give Make correct programe as you can.
Question2:
The atoms of different elements have different numbers of protons, neutrons and electrons. Electrons are negatively charged, protons are positively charged, and neutrons have no charge.
In an object oriented programming language of your choice, write a definition for an atom class that contains:
fields for storing the numbers of protons, neutrons and electrons with appropriate visibility;
setter and getter methods for manipulating these fields, ensuring that the minimum value for electrons and protons is 1, and the minimum value for neutrons is 0;
a constructor that initializes new objects of atom to be the smallest element (Hydrogen), for which the number of…
arrow_forward
In C++
Find the five errors. For each error, state the line number, explain the error and show a correction.
#include<iostream>
#include<iomanip>
using namespace std;
class colorCode
{
public:
void setRGB(int); //accepts an int parameter and sets the RGB to the value of the parameter
void setName(string);//accepts a string parameter and sets the name of the object to the value of the parameter
string getName() const;//returns the name of the object
int getRGB() const;//returns the RGB of the object
void changeColor();// adds 10 to the RGB value
private:
string name;
int RGB;
}
int main()
{
colorCode paintCans[10];
int i;
for (i = 0; i < 10; i++){
paintCans.setRGB[i] = 0;}
paintCans[5].setName(GREEN);
paintCan[5].setRGB(192000);
cout << paintCans[5].getName << ' ' << paintCans[5].getRGB() << endl;
return 0;
}
arrow_forward
Create a C++ Grocery Program according to this guideline:
Linked List
Functions
Pointers
Arrays
The program must have a menu layout where the user can select certain action (Select Product, View My Cart, Check-Out, etc.)
Include grocery items (e.g. Fruits, Vegetables, Drinks, etc.)
Implement basic error tapping
Include the group name of the developers with the name of each developer (a total of 4)
arrow_forward
ASAP
arrow_forward
Kindly answer the attached question using python without using any of its libraries
arrow_forward
Item 9/10
Time Left: 12:13
Python 3 is backwards compatible with Python 2
Select the true statements? (Select two answers)
Python is a good choice for creating and executing tests for applications
Python is free, open-source, and multiplatform
Python is a good choice for low-level programming, e.g., when you want to implement
an effective driver
+ Prev
Next >
arrow_forward
with python do whis:
Edit or delete a user profileWhen the user chooses 2, the first thing that it should do is to check whether the user information is loaded in the program (i.e., check if the user information is passed to the function that generates recipe recommendations). If the user information is passed to the function (i.e., the user chose option 1 before choosing option 2), the program should show the user the following menu:Hello (user name)You can perform one of the following operations:1) Delete your profile2) Edit your profilea. If the user chooses 1, perform the following subtasks to delete a user profile:1- Search for the user profile in the file userInformation.txt using the user name in read mode; once you find the user profile (i.e., the line that contains all the user information), pass it to a function that deletes the user information.2- The function should create a temporary file called temp.txt in write mode and search the file userInformation.txt in read mode…
arrow_forward
Exercise 2 - Primer on Loop
Referring to the code for drawing an equilateral triangle provided to you earlier in this prac
sheet, you may have noticed that, in order to draw the triangle, we are repeating a set of two
commands three times i.e. robot.forward( 100) followed by robotright(120). Python (and many other
programming languages) provide us a tool called a "Loop" to repeat a certain set of steps a
certain number of times. As usual, in order to use loops, we have learn the correct Python
syntax for it. The following Python code uses a loop to draw the same equilateral triangle as the
code provided earlier:
import turtle
wn - turtle.Screen()
wn.bgcolor("white"
robot - turtle. Turtle()
robot. setheading(90)
robot shape("turtle")
robot.colort"green"
robot. pensize(3)
for i in range(3):
robot. forward( 100)
robot. right(120)
wn.exitonclick()
Note that the lines that fall under the line that starts with "for" have to be indented; this means
that you have to insert spaces or tabs (USE…
arrow_forward
Convert from C to C++ .Thank you.
/ include all required libraries#include<stdio.h>#include<stdlib.h>#include<sys/types.h>#include<sys/wait.h>#include<unistd.h>
// variable to store number of generationsint num_generations;
// function to print the generationsvoid printGeneration(int n){// stop if number of generations are reachedif(n>num_generations)return;
// create a forkpid_t p = fork();
// generate new generationsif(p==0)printGeneration(n+1);else if(p>0)wait(0); // wait until child process terminates
// print the present generationif(p!=0){// if n is 0if(n==0)printf("Parent. "); // print parent// if n is 1else if(n==1)printf("Child. "); // print child// for all other caseselse{// print grandchildrenfor(int i=0;i<n-2;i++)printf("Great ");printf("Grandchild. ");}// print pid and ppidprintf("pid: %d ppid: %d\n",getpid(),getppid());}}
// main functionint main(int argc, char* argv[]){// if no arguments are providedif(argc==1){// print…
arrow_forward
Vo) 4G
LTE V
4G
ii 9:27
76
edube.org/learn/progra
3
Item 1/10
Time Left: 14:42
Select the true statements? (Select two
answers)
Python is free, open-source, and
multiplatform
Python is a good choice for low-level
programming, e.g., when you want to
implement an effective driver
Python is a good choice for creating
and executing tests for applications
Python 3 is backwards compatible
arrow_forward
C++ - No library functions like atoi
Write a machine language program to output your first name on the output device. Submit your "machine code" followed by a 'zz.'
An example of the machine code to output "hello" is shown below. This is an example of what a machine language submission would look like:
50 00 48 50 00 65 50 00 6c 50 00 6c 50 00 6f 00 zz
arrow_forward
Instruction: It should be a C++ PROGRAM INCLUDE THE HEADER FILE, MAIN CPP, AND BSTREE.CPP
There is a real program developed by a computer company that reads a report ( running text ) and issues warnings on style and partially corrects bad style. You are to write a simplified version of this program with the following features:
Statistics
A statistical summary with the following information:
Total number of words in the report
Number of unique words
Number of unique words of more than three letters
Average word length
Average sentence length
An index (alphabetical listing) of all the unique words (see next page for a specific format)
Style Warnings
Issue a warning in the following cases:
Word used too often: list each unique word of more than three letters if its usage is more than 5% of the total number of words of more than three letters
Sentence length : write a warning message if the average sentence length is greater than 10
Word length : write a warning message if the…
arrow_forward
Topical Information
Use C++. The purpose of this project is to test your ability to use files, strings (Strings?), and libraries effectively in program design.
Program Information
A popular past-time is the word search puzzle (if you don't believe me, look in your daily paper and in the news stand in the check-out line at the grocery store). In such a puzzle, a grid of letters is presented which presumably contains words. However, the words are cleverly hidden among the other letters. Their camouflage is aided by them being aligned in many different orientations: horizontal, vertical, diagonal, and sometimes even backwards! The person's goal is to find the words and circle each one. Most often the person is also given a list of the words which should be found:
apple hananabs
pear mpearoap
banana npsgrape
grape uleapnbm
orange…
arrow_forward
Find the bug in my simple python code and correct it. let me knwo if there are tab errors
# Course : ICT 4007: Creative Problem Solving and Programming Concepts
# Term : Fall 2021
# Program Name : Python Coding Project
# Author : Robel Geremew
# Date Written : 11/14/2021
# Description : This program demonstrates our understanding of classes, objects and arrays in python
# Declaring an employee class
class Employee:
def __init__(self, name):
self.name = name
def print_array (self,name):
emlpoyee = ["Homer" , "Lisa", "Marge", "Maggie", "Bart"]
for n in emlpoyee:
emlpoyee(n)
# Creating employee objects and accessing attributes
my_employee_1 = Employee("Homer")
print(" The first employee is " , my_employee_1.name)
my_employee_2 = Employee("Lisa")
print(" The Second employee is " , my_employee_2.name)
my_employee_3 = Employee("Marge")
print(" The Third employee is " ,…
arrow_forward
1. Compare the features of C#, Python and C++ programming languages. Use Google trends to
analyze the popularity of these languages among the programmers in Middle East region.
Provide screenshots to justify your results.
2. What is an Interface class? Explain with an example.
3. Consider the program below. What is the output of the program? If the break statement is
replaced with continue statement, what will be the output?
class hello {
public static void Main(String[] args) {
for (int i = 0; i <= 5; i++) {
if (i == 4) {
break;
+ i);
Console.Writeline("The number is
Console.ReadLine();
}
arrow_forward
Make a Calculator class that will be able to add, subtract, multiply, divide, find the remainder, percentage.
You need to use header file and source file for the class and create objects and call the functions from the main.cpp file
in C++ Programming
arrow_forward
please code in pythonThe library needs a program to store books’ information. Write a Python module manage.py that gets thebook information from the user store and prints them. The program will get the book's type, title,publication year, first author's name, and publisher name. The user can enter any book type, and theprogram should be able to store all of the related information and retrieve them. The prompt should showuntil the user enters 'done'. Next, the program should print books information based on the "type" and thepublication "year".The required spacing for each column is 15.Note: Inputs can be in either lower or upper case. However, the first letter of each word of the outputshould be capitalized.
arrow_forward
Task using C language
One common way of verifying if the data integrity of a file was preserved during a copy or transmission is to verify if the checksum matches. The checksum is a small piece of data computed from the original data. Your task is to compute a recursive function that maps an integer into a single digit to be used as checksum. Given an input integer in the range from 0 to 1012, the checksum is the sum of the digits of the input number. While the resulting sum has multiple digits, the checksum will be the sum of its digits instead. For instance:
if the input is 34, the checksum is 7 (3+4);
if the input is 99, the sum of its digits is 18 (9+9), so the checksum is 9 (1+8);
if the input is 99999999999, the sum of its digits is 99 (9+9+9+9+9+9+9+9+9+9+9), whose sum of digits is 18 (9+9), so the checksum is 9 (1+8).
Requirements
Follow the format of the examples below.
Make sure your variables and parameters have the correct data types.
You must implement a recursive…
arrow_forward
How can I apply this python code?
def createList(n): #Base Case/s #TODO: Add conditions here for your base case/s #if <condition> : #return <value> #Recursive Case/s #TODO: Add conditions here for your recursive case/s #else: #return <operation and recursive call>
#remove the line after this once you've completed all the TODO for this function return []
def removeMultiples(x, arr): #Base Case/s #TODO: Add conditions here for your base case/s #if <condition> : #return <value> #Recursive Case/s #TODO: Add conditions here for your recursive case/s #else: #return <operation and recursive call>
#remove the line after this once you've completed all the TODO for this function return [] def Sieve_of_Eratosthenes(list): #Base Case/s if len(list) < 1 : return list #Recursive Case/s else: return [list[0]] + Sieve_of_Eratosthenes(removeMultiples(list[0],…
arrow_forward
PuTTY/Ocelot
Assignment #2 Instructions: (using C language in the UNIX environment, Systems Programming)
Through this programming assignment, the students will learn to do the following:
Usage: mortgagepmt [-s] -r rate [-d downpayment] price
In this assignment, you are asked to perform a mortgage payment calculation. All information needed for this will be passed to the program on the command line. There will be no user input during the execution of the program
You will need a few pieces of information. The price of the home and the amount of the down payment. You will also need to know the interest rate and the term of the mortgage. To figure your mortgage payment, start by converting your annual interest rate to a monthly interest rate by dividing by 12. Next, add 1 to the monthly rate. Third, multiply the number of years in the term of the mortgage by 12 to calculate the number of monthly payments you'll make. Fourth, raise the result of 1 plus the monthly rate to the…
arrow_forward
Instructions for the assignment can be found in the picture linked to this post. The programs must be written in c++ and requires that the random number generator be seeded like this program:
Program 3.25
// This program demonstrates random numbers.
#include <iostream>
#include <cstdlib> // For rand and srand
#include <ctime> // For the time function
using namespace std;
int main()
{
// Get the system time.
unsigned seed = time(0);
// Seed the random number generator.
srand(seed);
// Display three random numbers.
cout << rand() << endl;
cout << rand() << endl;
cout << rand() << endl;
return 0;
}
arrow_forward
Instructions for the assignment can be found in the picture linked to this post. The programs must be written in c++ and requires that the random number generator be seeded like this program:
Program 3.25
// This program demonstrates random numbers.
#include <iostream>
#include <cstdlib> // For rand and srand
#include <ctime> // For the time function
using namespace std;
int main()
{
// Get the system time.
unsigned seed = time(0);
// Seed the random number generator.
srand(seed);
// Display three random numbers.
cout << rand() << endl;
cout << rand() << endl;
cout << rand() << endl;
return 0;
}
arrow_forward
python programming:
Topic: Functional model
Requirement: Write this program without matplotlib. Do not import matplotlib. You can use the math module
Without using matplotlib. Write a program one statement long (it can span multiple lines) that displays the curvature of a sinusoid on terminal. (one statement) Hint: the curve are made of characters.
arrow_forward
Loops summary: for vs. while
We have now seen that Python has two different loop constructs: the for loop and the while loop.
The while loop is more powerful than the for loop, since it can be used in situations where the number of iterations isn't known in advance. For
example, the following while loop answers the question: "If a population of bacteria increases in size by 21% every minute, how long does it take for
the population size to double?"
minutes = 0
population = 1000
growth_rate = 0.21
while population < 2000:
population *= (1 + growth_rate)
minutes += 1
print (f"{minutes} minutes required.")
print (f"Population = {int(population)}")
This would not be well suited to a for loop - we are trying to find out how many times the loop will run, and a for loop expects to know how many
times it will run before it starts.
In contrast, the for loop is a special case of the more general while loop, meaning that any program written with for loops can be rewritten to use
while loops.…
arrow_forward
write the pseudocode to process these tasks:
From the random module import randint to roll each die randomly
# in pseudocode, import a random function
# the name is helpful for the next M5-2 assignment
Define a class called Dice
In Python, the syntax has a colon after it: class Dice():
In pseudocode, you can specify it generally or be specific
Under the class declaration, list the attributes. Here are some tips:
# attributes are what we know about a single die (dice is plural)
# self is the first attribute in Python and must always appear first
# add a num_sides attribute and to set it to 6 for the 6 sides on the dice
Define a method for roll(self)
# it describes what happens when we roll a single die
# in the code, it will look like this example
def __init__(self, dice_sides=6):
# in pseudocode, we do not worry about the punctuation
# just list it as part of your logic
Under roll(self), return a random int value between 1 and self.dice_sides
arrow_forward
SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education
Related Questions
- C++ Programmingarrow_forwardRequirements for Your M5 Assignment 1 Pseudocode for Program Integration For the first module, write the pseudocode to process these tasks:(Note: lines beginning with # are comments with tips for you) From the random module import randint to roll each die randomly # in pseudocode, import a random function # the name is helpful for the next M5-2 assignment Define a class called Dice In Python, the syntax has a colon after it: class Dice(): In pseudocode, you can specify it generally or be specific Under the class declaration, list the attributes. Here are some tips: # attributes are what we know about a single die (dice is plural) # self is the first attribute in Python and must always appear first # add a num_sides attribute and to set it to 6 for the 6 sides on the dice Define a method for roll(self) # it describes what happens when we roll a single die # in the code, it will look like this example def __init__(self, dice_sides=6): # in pseudocode, we do not worry about…arrow_forwardDijkstra's algorithm Weight Class Implementationlanguage : C++ Note : Skelton Files Provided Please check the linksproject Details:https://ece.uwaterloo.ca/~dwharder/aads/Projects/5/Dijkstra/ Files:https://ece.uwaterloo.ca/~dwharder/aads/Projects/5/Dijkstra/src/ Please provide clear and complete solution for thumps up.arrow_forward
- Art.java In this part you will create a program Art.java that produces a recursive drawing of the design attached in the picture. Requirements Art.java must take one (1) integer command-line argument n that controls the depth of recursion. Your drawing must stay within the drawing window when n is between 1 and 7. (The autograder will not test values of n outside of this range.) You may not change the size of the drawing window (but you may change the scale). Do not add sound. Your drawing can be a geometric pattern, a random construction, or anything else that takes advantage of recursive functions. Optionally, you may use the Transform2D library you implemented in Part 1. You may also define additional geometric transforms in Art.java, such as sheer, reflect across the x- or y- axis, or rotate about an arbitrary point (as opposed to the origin). Your program must be organized into at least three separate functions, including main(). All functions except main() must be private. call…arrow_forwardlink - https://docs.python.org/3/library/time.html for time module Code - def long_running_task(n): num = 0 for x in range(n): for y in range(n): for z in range(n): num += x + y + z return num print(long_running_task(500))arrow_forwardInstructions: In Basic C Language In the code editor, you are provided with a main function that asks the user for an integer input and passes this value to a function called, getFactorial() The getFactorial() function has the following description: Return type - int Name - getFactorial Parameters - one integer Description - returns the factorial of the passed integer Your implementation should be RECURSIVE and you should not use any loops Input #include<stdio.h> int getFactorial(int); int main(void) { int n; printf("Enter n: "); scanf("%d", &n); printf("Factorial of %d is %d", n, getFactorial(n)); return 0;} int getFactorial(int n) { // TODO: Implement this recursive function} Output should be: Enter n: 3 Factorial of 3 is 6arrow_forward
- Scenario You are tasked to write a Python module named after you to help create score cards to students in a class. The following seven subject should show on each student’s score card: Algebra, English, Statistics. Our program should first ask for a student's name, then her/his scores for the three subjects in the order shown above. This process will be repeated until all the students’ scores are entered. Note that there are four (4) students and their names are the AB, CD, EF, GH. Use Python ASCII/UTF-8 functions chr and ord to generate the names; do not input the names manually. (Hint: You might need to use a dictionary and a function to accept all the input.) Create another function to handle the printing as follows: When the printing function is called, a single student name is passed to it as an argument. (e.g., function3(AB)), the function then prints the student’s name and his/her scores in two columns, one for the subjects and one for the scores. The subject and the…arrow_forwardC++ CODE DEBUG FIXING A rise will be given after giving me an explanation and output screen cut HERE IS DEBUG NOTE Dear Andy, I have withheld an assignment of a grade for two major reasons. The first is that the program does not demonstrate a knowledge of the usage of C++ class. The second is that the use of the compile-time library leads to some usages which are not standard C++ and which caused your program to fail to compile using my standard C++ compiler. I will explain these issues below. First, the usage of class has two data members specified as public. This is incorrect usage, because all data members in a C++ class must be specified as private. Therefore, access to them in the using program must use get and put methods. For example getSum and putSum, also getCount and putCount. These methods should appear under public. These methods and additional methods are the only way to access the data members of a class. In addition, your program has redefined sum and count as variables…arrow_forwardCourse: Object Oriented programming Lnaguage: C++ You have to solve the Make the program correctly and in 1 hours. kindly Make program correct as much as you can. Dont copy paste from any site or google do something that you can. please read question completly then give Make correct programe as you can. Question2: The atoms of different elements have different numbers of protons, neutrons and electrons. Electrons are negatively charged, protons are positively charged, and neutrons have no charge. In an object oriented programming language of your choice, write a definition for an atom class that contains: fields for storing the numbers of protons, neutrons and electrons with appropriate visibility; setter and getter methods for manipulating these fields, ensuring that the minimum value for electrons and protons is 1, and the minimum value for neutrons is 0; a constructor that initializes new objects of atom to be the smallest element (Hydrogen), for which the number of…arrow_forward
- In C++ Find the five errors. For each error, state the line number, explain the error and show a correction. #include<iostream> #include<iomanip> using namespace std; class colorCode { public: void setRGB(int); //accepts an int parameter and sets the RGB to the value of the parameter void setName(string);//accepts a string parameter and sets the name of the object to the value of the parameter string getName() const;//returns the name of the object int getRGB() const;//returns the RGB of the object void changeColor();// adds 10 to the RGB value private: string name; int RGB; } int main() { colorCode paintCans[10]; int i; for (i = 0; i < 10; i++){ paintCans.setRGB[i] = 0;} paintCans[5].setName(GREEN); paintCan[5].setRGB(192000); cout << paintCans[5].getName << ' ' << paintCans[5].getRGB() << endl; return 0; }arrow_forwardCreate a C++ Grocery Program according to this guideline: Linked List Functions Pointers Arrays The program must have a menu layout where the user can select certain action (Select Product, View My Cart, Check-Out, etc.) Include grocery items (e.g. Fruits, Vegetables, Drinks, etc.) Implement basic error tapping Include the group name of the developers with the name of each developer (a total of 4)arrow_forwardASAParrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education