Welcome to AssignmentCache!

Search results for 'q'

Items 1 to 10 of 41 total

per page
Page:
  1. 1
  2. 2
  3. 3
  4. 4
  5. 5

Grid  List 

Set Ascending Direction
  1. PRG 211 Week 5 Lab 11.1 Miles to track laps Program

    PRG 211 Week 5 Labs

    Regular Price: $20.00

    Special Price $15.00

    PRG 211 Week 5 Labs

    Lab 11.1 Miles to track laps

    One lap around a standard high-school running track is exactly 0.25 miles. Write a program that takes a number of miles as input, and outputs the number of laps.

    Ex: If the input is 1.5, the output is:
    6.0

    Ex: If the input is 2.2, the output is:
    8.8

    Your program should define and call a function:
    Function MilesToLaps(float userMiles) returns float userLaps


    Lab 11.2 Driving cost

    Write a function DrivingCost with parameters drivenMiles, milesPerGallon, and dollarsPerGallon, that returns the dollar cost to drive those miles. All items are of type float.

    Ex: If the function is called with 50 20.0 3.1599, the function returns 7.89975.

    Define that function in a program whose inputs are the car's miles/gallon and the gas dollars/gallon (both floats). Output the gas cost for 10 miles, 50 miles, and 400 miles, by calling your DrivingCost function three times.

    Ex: If the input is 20.0 3.1599, the output is:
    1.57995 7.89975 63.198

    Note: Small expression differences can yield small floating-point output differences due to computer rounding. Ex: (a + b)/3.0 is the same as a/3.0 + b/3.0 but output may differ slightly. Because our system tests programs by comparing output, please obey the following when writing your expression for this problem. In the DrivingCost function, use the variables in the following order to calculate the cost: drivenMiles, milesPerGallon, dollarsPerGallon.


    Lab 11.3 Step counter

    A pedometer treats walking 2,000 steps as walking 1 mile. Write a program whose input is the number of steps, and whose output is the miles walked. If the input is 5345, the output is 2.6725.

    Your program should define and call a function:
    Function StepsToMiles(integer userSteps) returns float numMiles


    Lab 11.4 Leap year

    A year in the modern Gregorian Calendar consists of 365 days. In reality, the earth takes longer to rotate around the sun. To account for the difference in time, every 4 years, a leap year takes place. A leap year is when a year has 366 days: An extra day, February 29th. The requirements for a given year to be a leap year are:

    1) The year must be divisible by 4

    2) If the year is a century year (1700, 1800, etc.), the year must be evenly divisible by 400

    Some example leap years are 1600, 1712, and 2016.

    Write a program that takes in a year and determines whether that year is a leap year. If the input is 1712, the output is: 1712 is a leap year. If the input is 1913, the output is: 1913 is not a leap year.

    Your program must define and call a function:

    Function OutputLeapYear(integer inputYear) returns nothing
    The function should output whether the input year is a leap year or not.


    Lab 11.5 Max and min numbers

    Write a program whose inputs are three integers, and whose outputs are the largest of the three values and the smallest of the three values. If the input is 7 15 3, the output is:
    largest: 15
    smallest: 3

    Your program should define and call two functions:
    Function LargestNumber(integer num1, integer num2, integer num3) returns integer largestNum
    Function SmallestNumber(integer num1, integer num2, integer num3) returns integer smallestNum
    The function LargestNumber should return the largest number of the three input values. The function SmallestNumber should return the smallest number of the three input values.


    Lab 11.6 Output values below an amount

    Write a program that first gets a list of six integers from input. The first five values are the integer list. The last value is the upper threshold. Then output all integers less than or equal to the threshold value.

    Ex: If the input is 50 60 140 200 75 100, the output is:
    50 60 75
    For coding simplicity, follow every output value by a space, including the last one.

    Such functionality is common on sites like Amazon, where a user can filter results.

    Your program should define and use a function:
    Function outputIntsLessThanOrEqualToThreshold(integer array(?) userVals, integer upperThreshold) returns nothing

    Learn More
  2. PRG 211 Week 4 Lab 9.2 Middle item Program

    PRG 211 Week 4 Labs

    Regular Price: $12.00

    Special Price $9.00

    PRG 211 Week 4 Labs

    Lab 9.1 Output numbers in reverse

    Write a program that reads a list of 10 integers, and outputs those integers in reverse. For coding simplicity, follow each output integer by a space, including the last one. Then, output a newline.

    Ex: If the input is 2 4 6 8 10 12 14 16 18 20, the output is:
    20 18 16 14 12 10 8 6 4 2
    To achieve the above, first read the integers into an array. Then output the array in reverse.


    Lab 9.2 Middle item

    Given a sorted list of integers, output the middle integer. Assume the number of integers is always odd.

    Ex: If the input is 2 3 4 8 11 -1 (a negative indicates end), the output is:
    4
    The maximum number of inputs for any test case should not exceed 9. If exceeded, output "Too many inputs".

    Hint: Use an array of size 9. First read the data into an array. Then, based on the number of items, find the middle item.


    Lab 9.3 Output values below an amount

    Write a program that first gets a list of 5 integers from input. Then, get another value from the input, and output all integers less than or equal to that value.

    Ex: If the input is 50 60 140 200 75 100, the output is:
    50 60 75
    For coding simplicity, follow every output value by a space, including the last one. Then, output a newline.

    Such functionality is common on sites like Amazon, where a user can filter results.

    Learn More
  3. PRG 211 Week 3 Lab 7.4 Countdown until matching digits Program

    PRG 211 Week 3 Labs

    Regular Price: $15.00

    Special Price $12.00

    PRG 211 Week 3 Labs

    Lab 7.1 Loops Convert to binary

    Write a program that takes in a positive integer as input, and outputs a string of 1's and 0's representing the integer in binary. For an integer x, the algorithm is:

    As long as x is greater than 0
    Output x % 2 (remainder is either 0 or 1)
    x = x / 2
    Note: The above algorithm outputs the 0's and 1's in reverse order.

    Ex: If the input is 6, the output is:
    011
    (6 in binary is 110; the algorithm outputs the bits in reverse).


    Lab 7.2 Loops Varied amount of input data

    Statistics are often calculated with varying amounts of input data. Write a program that takes any number of non-negative integers as input, and outputs the average and max. A negative integer ends the input and is not included in the statistics.

    Ex: When the input is 15 20 0 5 -1, the output is:
    10 20
    You can assume that at least one non-negative integer is input.


    Lab 7.3 Loops Output range with increment of 10

    Write a program whose input is two integers, and whose output is the first integer and subsequent increments of 10 as long as the value is less than or equal to the second integer.

    Ex: If the input is -15 30, the output is:
    -15 -5 5 15 25

    Ex: If the second integer is less than the first as in 20 5, the output is:
    Second integer can't be less than the first.

    For coding simplicity, output a space after every integer, including the last.


    Lab 7.4 Loops Countdown until matching digits

    Write a program that takes in an integer in the range 20-98 as input. The output is a countdown starting from the integer, and stopping when both output digits are identical.

    Ex: If the input is 93, the output is:
    93 92 91 90 89 88

    Ex: If the input is 77, the output is:
    77

    Ex: If the input is not between 20 and 98 (inclusive), the output is:
    Input must be 20-98

    For coding simplicity, follow each output number by a space, even the last one. Use a while loop. Compare the digits; do not write a large if-else for all possible same-digit numbers (11, 22, 33, ..., 88), as that approach would be cumbersome for large ranges.

    Learn More
  4. PRG 211 Week 2 Lab 5.3 Leap Year Program

    PRG 211 Week 2 Labs

    Regular Price: $12.00

    Special Price $9.00

    Lab 5.1 Largest number

    Write a program whose inputs are three integers, and whose output is the largest of the three values.

    Ex: If the input is 7 15 3, the output is:
    15


    Lab 5.2 Remove gray from RGB

    Summary: Given integer values for red, green, and blue, subtract the gray from each value.

    Computers represent color by combining the sub-colors red, green, and blue (rgb). Each sub-color's value can range from 0 to 255. Thus (255, 0, 0) is bright red, (130, 0, 130) is a medium purple, (0, 0, 0) is black, (255, 255, 255) is white, and (40, 40, 40) is a dark gray. (130, 50, 130) is a faded purple, due to the (50, 50, 50) gray part. (In other words, equal amounts of red, green, blue yield gray).

    Given values for red, green, and blue, remove the gray part.

    Ex: If the input is 130 50 130, the output is:
    80 0 80
    Find the smallest value, and then subtract it from all three values, thus removing the gray.

    Note: This page converts rgb values into colors.


    Lab 5.3 Leap Year

    A year in the modern Gregorian Calendar consists of 365 days. In reality, the earth takes longer to rotate around the sun. To account for the difference in time, every 4 years, a leap year takes place. A leap year is when a year has 366 days: An extra day, February 29th. The requirements for a given year to be a leap year are:

    1. The year must be divisible by 4
    2. If the year is a century year (1700, 1800, etc.), the year must be evenly divisible by 400
    Some example leap years are 1600, 1712, and 2016.

    Write a program that takes in a year and determines whether that year is a leap year.

    Ex: If the input is 1712, the output is:
    1712 is a leap year.

    Ex: If the input is 1913, the output is:
    1913 is not a leap year.

    Learn More
  5. PRG 211 Week 1 Lab 3.8 Using math functions Program

    PRG 211 Week 1 Labs

    Regular Price: $15.00

    Special Price $12.00

    Lab 3.1 Formatted Output Hello World!

    Write a program the outputs 'Hello World!'


    Lab 3.2 Formatted output: No parking sign.

    Write a program that prints a formatted "No parking" sign. Note the first line has two leading spaces.
    NO PARKING
    1:00 - 5:00 a.m.


    Lab 3.3 House real estate summary

    Sites like Zillow get input about house prices from a database and provide nice summaries for readers. Write a program with two inputs, current price and last month's price (both integers). Then, output a summary listing the price, the change since last month, and the estimated monthly mortgage computed as (currentPrice * 0.045) / 12.

    Ex: If the input is 200000 210000, the output is:

    This house is $200000. The change is $-10000 since last month.
    The estimated monthly mortgage is $750.0.
    Note: Getting the precise spacing, punctuation, and newlines exactly right is a key point of this assignment. Such precision is an important part of programming.


    Lab 3.4 Caffeine levels

    A half-life is the amount of time it takes for a substance or entity to fall to half its original value. Caffeine has a half-life of about 6 hours in humans. Given caffeine amount (in mg) as input, output the caffeine level after 6, 12, and 18 hours.

    Ex: If the input is 100, the output is:

    After 6 hours: 50.0 mg
    After 12 hours: 25.0 mg
    After 18 hours: 12.5 mg
    Note: A cup of coffee has about 100 mg. A soda has about 40 mg. An "energy" drink (a misnomer) has between 100 mg and 200 mg.


    Lab 3.5 Divide by x.

    Write a program using integers userNum and x as input, and output userNum divided by x four times.

    Ex: If the input is 2000 2, the output is:

    1000 500 250 125
    Note: In Coral, integer division discards fractions. Ex: 6 / 4 is 1 (the 0.5 is discarded).


    Lab 3.6 Driving costs.

    Driving is expensive. Write a program with a car's miles/gallon and gas dollars/gallon (both floats) as input, and output the gas cost for 10 miles, 50 miles, and 400 miles.

    Ex: If the input is 20.0 3.1599, the output is:

    1.57995 7.89975 63.198
    Note: Small expression differences can yield small floating-point output differences due to computer rounding. Ex: (a + b)/3.0 is the same as a/3.0 + b/3.0 but output may differ slightly. Because our system tests programs by comparing output, please obey the following when writing your expression for this problem. First use the dollars/gallon and miles/gallon values to calculate the dollars/mile. Then use the dollars/mile value to determine the cost per 10, 50, and 400 miles.

    Note: Real per-mile cost would also include maintenance and depreciation.


    Lab 3.7 Simple statistics.

    Part 1
    Given 3 integers, output their average and their product, using integer arithmetic.

    Ex: If the input is 10 20 5, the output is:

    11 1000
    Note: Integer division discards the fraction. Hence the average of 10 20 5 is output as 11, not 11.666666666666666.

    Submit the above for grading. Your program will fail the test cases (which is expected), until you complete part 2 below but check that you are getting the correct average and product using integer division.

    Part 2
    Also output the average and product, using floating-point arithmetic.

    Ex: If the input is 10 20 5, the output is:

    11 1000
    11.666666666666666 1000.0


    Lab 3.8 Using math functions

    Given three floating-point numbers x, y, and z, output x to the power of y, x to the power of (y to the power of z), the absolute value of x, and the square root of (xy to the power of z).

    Ex: If the input is 5.0 6.5 3.2, the output is:

    34938.56214843421 1.2995143401732918e+279 5.0 262.42993783925596
    Hint: Coral has built-in math functions (discussed elsewhere) that may be used.


    Function Behavior Example
    SquareRoot(x) Square root of x SquareRoot(9.0) evaluates to 3.0.
    RaiseToPower(x, y) Raise x to power y: RaiseToPower(6.0, 2.0) evaluates to 36.0.
    AbsoluteValue(x) Absolute value of x AbsoluteValue(-99.5) evaluates to 99.5.

    Learn More
  6. IT 140 HigherLower Game Pseudocode Project One

    IT 140 Higher/Lower Game Pseudocode Project One

    Regular Price: $8.00

    Special Price $5.00

    IT 140 Higher/Lower Game Pseudocode Project One

    Higher/Lower Game Description
    Your friend Maria has come to you and said that she has been playing the higher/lower game with her three-year-old daughter Bella. Maria tells Bella that she is thinking of a number between 1 and 10, and then Bella tries to guess the number. When Bella guesses a number, Maria tells her whether the number she is thinking of is higher or lower or if Bella guessed it. The game continues until Bella guesses the right number. As much as Maria likes playing the game with Bella, Bella is very excited to play the game all the time. Maria thought it would be great if you could create a program that allows Bella to play the game as much as she wants.

    For this assignment, you will be designing pseudocode for a higher/lower game program. The higher/lower game program uses similar constructs to the game you will design and develop in Projects one and Two.

    1) Review the Higher/Lower Game Sample Output for more detailed examples of this game. As you read, consider the following questions:
    What are the different steps needed in this program? How can you break them down in a way that a computer can understand?
    What information would you need from the user at each point (inputs)? What information would you output to the user at each point?
    When might it be a good idea to use "IF" and "IF ELSE" statements?
    When might it be a good idea to use loops?

    2) Create a pseudocode that logically outlines each step of the game program so that it meets the following functionality:
    Prompts the user to input the lower bound and upper bound. Include input validation to ensure that the lower bound is less than the upper bound.
    Generates a random number between the lower and upper bounds
    Prompts the user to input a guess between the lower and upper bounds. Include input validation to ensure that the user only enters values between the lower and upper bound.
    Prints an output statement based on the guessed number. Be sure to account for each of the following situations through the use of decision branching:
    What should the computer output if the user guesses a number that is too low?
    What should the computer output if the user guesses a number that is too high?
    What should the computer output if the user guesses the right number?
    Loops so that the game continues prompting the user for a new number until the user guesses the correct number.

    OPTIONAL: If you would like to practice turning your designs into code, check out the optional 9.1 LAB: Higher/Lower Game in zyBooks. This step is optional but will give you additional practice turning designs into code, which will support your work in moving from Project One to Project Two.

    Learn More
  7. DAT210 Week 5 Python 6.23 Python insert update sqlite3 datafiles

    DAT/210 Week 5 Python 6.23: Python insert/update sqlite3 datafiles

    Regular Price: $10.00

    Special Price $4.00

    DAT/210 Week 5 Python 6.23: Python insert/update sqlite3 datafiles

    Given is a Python program that connects to a sqlite database and has one table called writers with two columns:
    • name - the name of a writer
    • num - the number of works the writer has written

    The writers table originally has the following data
    name, num
    Jane Austen,6
    Charles Dickens,20
    Ernest Hemingway,9
    Jack Kerouac,22
    F. Scott Fitzgerald,8
    Mary Shelley,7
    Charlotte Bronte,5
    Mark Twain,11
    Agatha Christie,73
    Ian Flemming,14
    J.K. Rowling,14
    Stephen King,54
    Oscar Wilde,1
    Update the Python program to ask the user if they want to update entries or add new entries. If the name entered already exists in the writers table then the database record is updated, overwriting the original contents. If the name does not exist in the writers table, then add a new record with the writers name and number of works. The following TODO sections must be completed.
    • Check if a writer exists in the writers table
    • If the writer exists in the table, locate an entry to be updated by writers name and update the writer's value for num
    • If the writer does not exist in the table, add a new entry in the writers table and provide the value for name and num

    Ex if the input is:
    y
    J.K. Rowling
    30
    y
    Elton John
    y
    62
    n
    The output is:
    (ID, Name, Num)
    (1, 'Jane Austen', 6)
    (2, 'Charles Dickens', 20)
    (3, 'Ernest Hemingway', 9)
    (4, 'Jack Kerouac', 22)
    (5, 'F. Scott Fitzgerald', 8)
    (6, 'Mary Shelley', 7)
    (7, 'Charlotte Bronte', 5)
    (8, 'Mark Twain', 11)
    (9, 'Agatha Christie', 73)
    (10, 'Ian Flemming', 14)
    (11, 'J.K. Rowling', 30)
    (12, 'Stephen King', 54)
    (13, 'Oscar Wilde', 1)
    (14, 'Elton John', 62)

    Learn More
  8. DAT210 Week 5 Python LAB 6.22 Python and sqlite basics

    DAT/210 Week 5 Python LAB 6.22: Python and sqlite basics

    Regular Price: $10.00

    Special Price $4.00

    DAT/210 Week 5 Python LAB 6.22: Python and sqlite basics

    Write a Python program that connects to a sqlite database.
    Create a table called Horses with the following fields:
    • id (integer): a primary key and not null
    • name (text)
    • breed (text)
    • height (real)
    • birthday (text)

    Next, insert the following data row into the Horses table:
    id: 1
    name: 'Babe'
    breed: 'Quarter Horse'
    height: 15.3
    birthday: '2015-02-10'
     
    Output all records from the Horses table.
    Ex: With the above row inserted, the output should be:
    All Horses:
    (1, 'Babe', 'Quarter Horse', 15.3, '2015-02-10')

    Learn More
  9. DAT210 Week 5 Python LAB 6.20 Output values in a list below a user defined amount

    DAT/210 Week 5 Python LAB 6.20: Output values in a list below a user defined amount

    Regular Price: $7.00

    Special Price $4.00

    DAT/210 Week 5 Python LAB 6.20: Output values in a list below a user defined amount

    Write a program that first gets a list of integers from input. The input begins with an integer indicating the number of integers that follow. Then, get the last value from the input, which indicates a threshold. Output all integers less than or equal to that last threshold value.

    Ex If the input is:
    5
    50
    60
    140
    200
    75
    100
    the output is:
    50 60 75

    The 5 indicates that there are five integers in the list, namely 50, 60,140, 200, and 75. The 100 indicates that the program should output all integers less than or equal to 100, so the program outputs 50, 60, and 75.
    Such functionality is common on sites like Amazon, where a user can filter results.

    Learn More
  10. DAT210 Week 4 Python LAB 5.24 Leap year

    DAT/210 Week 4 Python LAB 5.24: Leap year

    Regular Price: $7.00

    Special Price $3.00

    DAT/210 Week 4 Python LAB 5.24: Leap year

    A year in the modern Gregorian Calendar consists of 365 days. In reality, the earth takes longer to rotate around the sun. To account for the difference in time, every 4 years, a leap year takes place. A leap year is when a year has 366 days: An extra day, February 29th. The requirements for a given year to be a leap year are:
    1) The year must be divisible by 4
    2) If the year is a century year (1700, 1800, etc.), the year must be evenly divisible by 400
    Some example leap years are 1600, 1712, and 2016.

    Write a program that takes in a year and determines whether that year is a leap year.
    Ex: If the input is:
    1712
    the output is:
    1712 - leap year

    Ex: If the input is:
    1913
    the output is:
    1913 - not a leap year

    main. py
    is_leap_year = False
    input_year = int(input())
    '''Type your code here. '''

    Learn More

Items 1 to 10 of 41 total

per page
Page:
  1. 1
  2. 2
  3. 3
  4. 4
  5. 5

Grid  List 

Set Ascending Direction
[profiler]
Memory usage: real: 14680064, emalloc: 14441208
Code ProfilerTimeCntEmallocRealMem