# Posts Tagged ‘Python’

## Suppose that the tuition for a university is $10,000 this year and increases 5% every year. In one year, the tuition will be $10,500. Write a program that displays the tuition in 10 years and the total cost of 4 years worth of tuition starting after the 10th year.

Suppose that the tuition for a university is $10,000 this year and increases 5% every year. In one year, the tuition will be $10,500. Write a program that displays the tuition in 10 years and the total cost of 4 years’ worth of tuition starting after the 10th year.

Read More## Using loops, write a program that finds the largest prime number smaller than 10,000

Using loops, write a program that finds the largest prime number smaller than 10,000

Read More## Write a program that takes the account’s present value, monthly interest rate, and the number of months that the money will be left in the account as three inputs from the user.

LANGUAGE: PYTHON CHALLENGE: Suppose you have a certain amount of money in a savings account that earns compound monthly interest, and you want to calculate the amount that you will have after a specific number of months. The formula is as follows: f = p * (1 + i)^t • f is the future value…

Read More## Write a Boolean function named is_prime which takes an integer as an argument and returns true if the argument is a prime number, or false otherwise. Use the function in a program that prompts the user to enter a number and then prints whether the number is prime.

LANGUAGE: PYTHON CHALLENGE: A prime number is a number that is only evenly divisble by itself and 1. For example, the number 5 is prime because it can only be evenlly divided by 1 and 5. The number 6, however, is not prime because it can be divided evenly by 2 and 3. Write a…

Read More## Write an expression (not a statement!) whose value is the largest of population1, population2, population3, and population4 by calling max2.

LANGUAGE: PYTHON CHALLENGE: assume that max2 is a function that expects two int parameters and returns the value of the larger one. Also assume that four variables , population1, population2, population3, and population4 have already been defined and associated with int values. Write an expression (not a statement!) whose value is the largest of population1,…

Read More## Write an expression (not a statement!) whose value is the larger of population1 and population2 by calling max.

LANGUAGE: PYTHON CHALLENGE: max is a function that expects two int parameters and returns the value of the larger one. Two variables , population1 and population2, have already been defined and associated with int values. Write an expression (not a statement!) whose value is the larger of population1 and population2 by calling max.

Read More## Define a function called min that takes two parameters containing integer values and returns the smaller integer of the two. If they have equal value, return either one.

LANGUAGE: PYTHON CHALLENGE: Define a function called min that takes two parameters containing integer values and returns the smaller integer of the two. If they have equal value, return either one.

Read More## Define a function called isSenior that takes a parameter containing an integer value and returns True if the parameter is greater than or equal to 65, and False otherwise

LANGUAGE: PYTHON CHALLENGE: Define a function called isSenior that takes a parameter containing an integer value and returns True if the parameter is greater than or equal to 65, and False otherwise

Read More## Define a function called signOf that takes a parameter containing an integer value and returns a 1 if the parameter is positive, 0 if the parameter is 0, and -1 if the parameter is negative

LANGUAGE: PYTHON CHALLENGE: Define a function called signOf that takes a parameter containing an integer value and returns a 1 if the parameter is positive, 0 if the parameter is 0, and -1 if the parameter is negative

Read More## Write the definition of a function absoluteValue that receives a parameter containing an integer value and returns the absolute value of that parameter.

LANGUAGE: PYTHON CHALLENGE: Write the definition of a function absoluteValue that receives a parameter containing an integer value and returns the absolute value of that parameter.

Read More## [Functions >> functions and if statements] Write the definition of a function powerTo which receives two parameters, a double and an integer.

LANGUAGE: PYTHON CHALLENGE: [Functions >> functions and if statements] Write the definition of a function powerTo which receives two parameters, a double and an integer. If the second parameter is positive, the function returns the value of the first parameter raised to the power of the second. Otherwise, the function returns 0.

Read More## Write the definition of a function oneLess which receives a parameter containing an integer value and returns an integer whose value is one less than the value of the parameter.

LANGUAGE: PYTHON CHALLENGE: Write the definition of a function oneLess which receives a parameter containing an integer value and returns an integer whose value is one less than the value of the parameter.

Read More