CPSC1280_Lab8+version2-python
.docx
keyboard_arrow_up
School
Langara College *
*We aren’t endorsed by this school
Course
1280
Subject
Computer Science
Date
Dec 6, 2023
Type
docx
Pages
4
Uploaded by KidGrousePerson67
CPSC 1280 – Lab 8
Pre-lab activity
a.
Login to AWS Cloud9
b.
Create a folder, Lab8-yourstudentID
Store all your data and work in this folder
c.
Work independently
Problem 1: Simple Calculator
Create a program that performs basic arithmetic operations (addition, subtraction, multiplication, division)
on two numbers.
Requirements:
Use variables to store the numbers and the result.
The program should ask the user for the numbers and the operation to perform.
Sample Output:
Enter the first number: 10
Enter the second number: 5
Choose operation (+, -, *, /): +
Result: 15
Problem 2: Counting Vowels and Consonants
Write a program that counts the number of vowels and consonants in a given string.
Requirements:
The program should ask the user for a string input.
Sample Output:
Enter a string: Hello World
Number of vowels: 3
Number of consonants: 7
Problem 3: Factorial Calculator
Write a function to calculate the factorial of a number.
Requirements:
The function should take a single argument and return the factorial.
Test the function with different numbers.
Sample Output:
Factorial of 5 is 120
1
CPSC 1280 – Lab 8
Problem 4:
Calculate the area and perimeter of a rectangle.
Requirements:
Use variables for the dimensions of the rectangle and the results.
Ask the user for the dimensions.
Sample Output:
Enter length: 5
Enter width: 10
Area: 50
Perimeter: 30
Problem 5:
Read a CSV file containing names and ages and print the names of people older than 20.
Requirements:
Read from a CSV file.
Sample Data: (filename: prob5data.csv )
Name,Age
Alice,22
Bob,18
Cathy,25
Sample Output:
Alice
Cathy
Problem 6:
Take names and grades from the user and write them to a CSV file.
Requirements:
Write to a CSV file.
Sample Output: (destination filename: prob6data.csv
(Sample contents of CSV file and the format)
Alice,A
Bob,B
Problem 7:
2
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
INSTRUCTION: C++ language
arrow_forward
Please help me with this. I am having trouble understanding what to do.
Programming Language: HTML, CSS, JavaScript
Please just draw the flowchart
Thank you
arrow_forward
Instructions
The files provided in the code editor to the right contain syntax and/or logic errors. In each case, determine and fix the problem, remove all syntax and coding errors, and run the program to ensure it works properly.
An example of the program is shown below:
Enter an integer >> 13 Enter a second integer >> 24 Enter a third integer >> 101 The sum of 13 and 24 is 37 The sum of 24 and 101 is 125 The sum of 13 and 101 is 114 The difference between 13 and 24 is -11 The difference between 24 and 101 is -77 The difference between 13 and 101 is -88
Task 1: The DebugThree3 class compiles without error.
Task 2: The add() method adds two integers.
Task 3: The subtract() method subtracts two integers.
Task 4: The DebugThree2 program accepts user input and displays the correct output.
arrow_forward
Instructions
The files provided in the code editor to the right contain syntax and/or logic errors. In each case, determine and fix the problem, remove all syntax and coding errors, and run the program to ensure it works properly.
An example of the program is shown below:
Enter an integer >> 13 Enter a second integer >> 24 Enter a third integer >> 101 The sum of 13 and 24 is 37 The sum of 24 and 101 is 125 The sum of 13 and 101 is 114 The difference between 13 and 24 is -11 The difference between 24 and 101 is -77 The difference between 13 and 101 is -88
Task 1: The DebugThree3 class compiles without error.
Task 2: The add() method adds two integers.
Task 3: The subtract() method subtracts two integers.
Task 4: The DebugThree2 program accepts user input and displays the correct output.
arrow_forward
Don't Copy from other website I will rate
arrow_forward
DEADLOCK MANAGEMENT TECHNIQUE Write a program to simulate the Banker’s algorithm for the purpose of deadlock avoidance. Your program receives as input the number of processes in the systems and how many devices each job requires to complete execution. Your program shows how devices are allocated to each process as it executes and if the system is currently in a safe or unsafe state. USE JAVA
arrow_forward
Intro to Python Programming:
ATM Application
When you use an automated teller machine (ATM) with your bank card, you needto use a personal identification number (PIN) to access your account. If a user failsmore than three times when entering the PIN, the machine will block the card.Create the ATM Application.The application asks the user for the PIN no more than three times, and does thefollowing:• If the user enters the right PIN, the application should ask the user to choose anaccount (checking or savings), and display its balance.• If the user enters a wrong PIN and, if the application has asked for the PIN lessthan three times, it should ask for it again.• If the user enters a wrong PIN three times, the application should print amessage saying “Your bank card is blocked”.Assume that the user’s checking account balance is $1450.56 and his/her savingsaccount balance is $10. Also assume the user’s PIN is “9554”.
SAMPLE RUNEnter your PIN: 1353Enter your PIN: 9555Enter your PIN:…
arrow_forward
download it to see the clear image thanks :)
please read the instructions
arrow_forward
C language
The program should allow users to add, subtract, multiply, and divide fractions.
The program should display a menu and prompt the user for a mathematical operation, until they enter 5 to exit. The menu should give the user the option to add, subtract, multiply or divide fractions, or exit. After the user chooses their option, they should be prompted to input two fractions. The result of the arithmetic should then be displayed to the screen.
Requirements
main()Functionality: This main function should prompt the user for a menu option until they enter 5. If the user doesn't choose Option 5 to end the program, it should get two fractions from the user. It should decide, based on the menu option which actions to perform on the fractions. Option 1 adds the two fractions together. Option 2 subtracts the first fraction from the second. Option 3 multiplies the two fractions together. Option 4 divides the first fraction by the second one.
In addition to the main functions, your…
arrow_forward
1.Complete Steps 1-7 in the comments below. The remaining comments explain the logic. Customers can check a variety of loans and interest rates. When finished, type quit
# Step 1: add an input statement to enter name or type quit to exit
# Step 2: add a while loop to keep asking for a name until the user types quit
# Step 3: declare two variables for loan and interest, like months below, # convert them to float, and ask the user to input their values to the screen.
months = float(input("How many months will it take to repay your loan? "))
print("***************************************************************") print (name, "you requested an estimate on a loan for {0:.2f}" .format(loan))
# Step 4: add a print statement to display the interest and # of months
print("*******************************************************************************") print("Here are the rates for simple interest, compound interest, and monthly interest", "\n")…
arrow_forward
c++
arrow_forward
Assignment 2 is worth 20% of the final module grade and is due at the end of Week 2 by 11.59 p.m. (23.59) VLE (UTC)
OVERVIEW
Create a simple currency converter that converts the user’s input from US Dollars (USD) to British Pound (GDP)
DELIVERABLES
Required elements of application
A message to prompt user input
A fixed variable that stores the most recent exchange rate of the British Pound (£)
User input (variable) should be used to calculate the exchange rate and display it back to the user.
arrow_forward
Instructions
The files provided in the code editor to the right contain syntax and/or logic errors. In each case, determine and fix the problem, remove all syntax and coding errors, and run the program to ensure it works properly.
An example of the program is shown below:
Enter credits for first student >> 18 Enter credits for second student >> 30 Total due for student #1 is $1365.1200000000001 Total due for student #2 is $2275.2000000000003
Task 1: The DebugThree4 class compiles without error.
Task 2: The computeTuitionBill() method computes and displays the correct tuition bill.
Task 3: The DebugThree4 program accepts user input and displays the correct output.
arrow_forward
Draw hierarchy charts or flowcharts that depict the programs described below.
Sales TaxDesign a hierarchy chart or flowchart for a program that calculates the total of aretail sale. The program should ask the user for:– The retail price of the item being purchased– The sales tax rateOnce these items have been entered, the program should calculate and display:– The sales tax for the purchase– The total of the sale
arrow_forward
Zodiac Sign
Capricorn
Aquarius
Pisces
Aries
Taurus
Gemini
Cancer
Leo
Virgo
Libra
Scorpio
Sagittarius
Date Range
December 22 to January 19
January 20 to February 18
February 19 to March 20
March 21 to April 19
April 20 to May 20
May 21 to June 20
June 21 to July 22
July 23 to August 22
August 23 to September 22
September 23 to October 22
October 23 to November 21
November 22 to December 21
Write a program that asks the user to enter user's month and day of birth. Then your program
should report the user's zodiac sign as part of an appropriate output message.
You don't need to use loops if you use them use exit condition such a yes/no with an appropriate
prompt.
Make sure you test the program properly dates such a 0 or number greater that 31 should be
classified as errors. Similarly, treat any month less than 1 and greater than 12 as error.
The rest is simple, sample test case.
Please enter your month of birth as a number: 2
Please enter your day of birth as a number: 12
You are a…
arrow_forward
SEE MORE QUESTIONS
Recommended textbooks for you
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:9781337102124
Author:Diane Zak
Publisher:Cengage Learning
Related Questions
- INSTRUCTION: C++ languagearrow_forwardPlease help me with this. I am having trouble understanding what to do. Programming Language: HTML, CSS, JavaScript Please just draw the flowchart Thank youarrow_forwardInstructions The files provided in the code editor to the right contain syntax and/or logic errors. In each case, determine and fix the problem, remove all syntax and coding errors, and run the program to ensure it works properly. An example of the program is shown below: Enter an integer >> 13 Enter a second integer >> 24 Enter a third integer >> 101 The sum of 13 and 24 is 37 The sum of 24 and 101 is 125 The sum of 13 and 101 is 114 The difference between 13 and 24 is -11 The difference between 24 and 101 is -77 The difference between 13 and 101 is -88 Task 1: The DebugThree3 class compiles without error. Task 2: The add() method adds two integers. Task 3: The subtract() method subtracts two integers. Task 4: The DebugThree2 program accepts user input and displays the correct output.arrow_forward
- Instructions The files provided in the code editor to the right contain syntax and/or logic errors. In each case, determine and fix the problem, remove all syntax and coding errors, and run the program to ensure it works properly. An example of the program is shown below: Enter an integer >> 13 Enter a second integer >> 24 Enter a third integer >> 101 The sum of 13 and 24 is 37 The sum of 24 and 101 is 125 The sum of 13 and 101 is 114 The difference between 13 and 24 is -11 The difference between 24 and 101 is -77 The difference between 13 and 101 is -88 Task 1: The DebugThree3 class compiles without error. Task 2: The add() method adds two integers. Task 3: The subtract() method subtracts two integers. Task 4: The DebugThree2 program accepts user input and displays the correct output.arrow_forwardDon't Copy from other website I will ratearrow_forwardDEADLOCK MANAGEMENT TECHNIQUE Write a program to simulate the Banker’s algorithm for the purpose of deadlock avoidance. Your program receives as input the number of processes in the systems and how many devices each job requires to complete execution. Your program shows how devices are allocated to each process as it executes and if the system is currently in a safe or unsafe state. USE JAVAarrow_forward
- Intro to Python Programming: ATM Application When you use an automated teller machine (ATM) with your bank card, you needto use a personal identification number (PIN) to access your account. If a user failsmore than three times when entering the PIN, the machine will block the card.Create the ATM Application.The application asks the user for the PIN no more than three times, and does thefollowing:• If the user enters the right PIN, the application should ask the user to choose anaccount (checking or savings), and display its balance.• If the user enters a wrong PIN and, if the application has asked for the PIN lessthan three times, it should ask for it again.• If the user enters a wrong PIN three times, the application should print amessage saying “Your bank card is blocked”.Assume that the user’s checking account balance is $1450.56 and his/her savingsaccount balance is $10. Also assume the user’s PIN is “9554”. SAMPLE RUNEnter your PIN: 1353Enter your PIN: 9555Enter your PIN:…arrow_forwarddownload it to see the clear image thanks :) please read the instructionsarrow_forwardC language The program should allow users to add, subtract, multiply, and divide fractions. The program should display a menu and prompt the user for a mathematical operation, until they enter 5 to exit. The menu should give the user the option to add, subtract, multiply or divide fractions, or exit. After the user chooses their option, they should be prompted to input two fractions. The result of the arithmetic should then be displayed to the screen. Requirements main()Functionality: This main function should prompt the user for a menu option until they enter 5. If the user doesn't choose Option 5 to end the program, it should get two fractions from the user. It should decide, based on the menu option which actions to perform on the fractions. Option 1 adds the two fractions together. Option 2 subtracts the first fraction from the second. Option 3 multiplies the two fractions together. Option 4 divides the first fraction by the second one. In addition to the main functions, your…arrow_forward
- 1.Complete Steps 1-7 in the comments below. The remaining comments explain the logic. Customers can check a variety of loans and interest rates. When finished, type quit # Step 1: add an input statement to enter name or type quit to exit # Step 2: add a while loop to keep asking for a name until the user types quit # Step 3: declare two variables for loan and interest, like months below, # convert them to float, and ask the user to input their values to the screen. months = float(input("How many months will it take to repay your loan? ")) print("***************************************************************") print (name, "you requested an estimate on a loan for {0:.2f}" .format(loan)) # Step 4: add a print statement to display the interest and # of months print("*******************************************************************************") print("Here are the rates for simple interest, compound interest, and monthly interest", "\n")…arrow_forwardc++arrow_forwardAssignment 2 is worth 20% of the final module grade and is due at the end of Week 2 by 11.59 p.m. (23.59) VLE (UTC) OVERVIEW Create a simple currency converter that converts the user’s input from US Dollars (USD) to British Pound (GDP) DELIVERABLES Required elements of application A message to prompt user input A fixed variable that stores the most recent exchange rate of the British Pound (£) User input (variable) should be used to calculate the exchange rate and display it back to the user.arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Programming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:CengageC++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningC++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology Ptr
- Programming with Microsoft Visual Basic 2017Computer ScienceISBN:9781337102124Author:Diane ZakPublisher:Cengage Learning
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:9781337102124
Author:Diane Zak
Publisher:Cengage Learning