1.4 KiB
Executable File
Exercícios propostos no CodeCheck
Ex 1.
height = 4.5
width = 3
volume1 = balloonVolume(width, height)
print("Original volume: ", volume1)
volume2 = balloonVolume(width + 1, height + 1)
change = volume2 - volume1
print("Change: ", change)
change = balloonVolume(width + 2, height + 2) - volume2
print("Change: ", change)
Ex 2.
def balloonVolume(width, height):
pi = 3.1415926
a = height / 2
c = width / 2
volume = 4 * pi * a * c * c / 3
return volume
Ex 3.
def hideCharacters(string) :
return "*" * len(string)
Ex 4.
def isEven(n):
if n % 2 == 0:
return True
else:
return False
def main() :
page = int(input("Enter page number: "))
if isEven(page) :
print(page)
else :
print("%60d" % page)
main()
Ex 5.
def countSpaces(string):
spaces = 0
for char in string:
if char == " ":
spaces += 1
return spaces
def main() :
userInput = input("Enter a string: ")
spaces = countSpaces(userInput)
print(spaces)
main()