# Python

Need Help in Python Assignment?
We can help you if you are having difficulty with your Python Assignment. Just email your Java Assignment at admin@assignmentcache.com.
We provide help for students all over the world in Python Assignment.

Items 11 to 20 of 105 total

per page
Page:
1. ## PRG/211 Week 3 Lab 7.3 Loops: Output range with increment of 10

Regular Price: \$8.00

Special Price: \$3.00

PRG/211 Week 3 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.

2. ## PRG/211 Week 3 Lab 7.2 Loops: Varied amount of input data

Regular Price: \$8.00

Special Price: \$3.00

PRG/211 Week 3 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.

3. ## PRG/211 Week 3 Lab 7.1 Loops: Convert to binary

Regular Price: \$8.00

Special Price: \$3.00

PRG/211 Week 3 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).

4. ## PRG/211 Week 2 Lab 5.3: Leap Year

Regular Price: \$8.00

Special Price: \$3.00

PRG/211 Week 2 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.

5. ## PRG/211 Week 2 Lab 5.2: Remove gray from RGB

Regular Price: \$8.00

Special Price: \$3.00

PRG/211 Week 2 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.

6. ## PRG/211 Week 2 Lab 5.1: Largest number

Regular Price: \$8.00

Special Price: \$3.00

PRG/211 Week 2 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

7. ## PRG/211 Week 1 Lab 3.8: Using math functions

Regular Price: \$8.00

Special Price: \$3.00

PRG/211 Week 1 Lab 3.8.1: 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.

8. ## PRG/211 Week 1 Lab 3.7: Simple statistics

Regular Price: \$8.00

Special Price: \$3.00

PRG/211 Week 1 Lab 3.7.1: 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

9. ## PRG/211 Week 1 Lab 3.6: Driving costs

Regular Price: \$8.00

Special Price: \$3.00

PRG/211 Week 1 Lab 3.6.1: 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.

10. ## PRG/211 Week 1 Lab 3.5: Divide by x

Regular Price: \$8.00

Special Price: \$3.00

PRG/211 Week 1 Lab 3.5.1: 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).