Python Exercises

#1 - Create a variable named movie. Set it equal to your favorite movie. Movie = "Avengers:Endgame" #2 - Is the variable you created in Problem the first problem a String, Integer, or Float? It's a string, since "Avengers:Endgame" is a word. #3 - Print the variable named movie. print(movie) #4 - Create an integer variable x and set it equal to 10. x = 10 #5 - What type of variable is x? It is an integer variable since 10 is an integer (whole number). #6 - Create a variable called y and set it equal to 33.5. y = 33.5 #7 - What type of variable is y? y is a float, since 33.5 is a decimal number. #8 - Print the result of adding x and y together. print(x + y) Exercise 2 #1 name = "Elijah" age = 13 print("My name is " + name + ", and I'm " + str(age) + " years old.") #2 x = 20 print(x* 20) #3 decimal = "22.5" decimal = float(decimal) result = decimal * 4 print(result) Exercise 3 print("Hi I Am COE Which Is Calculator 0f Elijah") num1 = int(input("Type Your First Number:")) num2 = int(input ("Type Your Second Number:")) num3 = int(input ("Type Your Third Number:")) operator =(input ("Type a Operator:")) if (operator == "-"): answer = num1 - num2 - num3 elif (operator == "+"): answer = num1 + num2 + num3 elif (operator == "*"): answer = num1 * num2 * num3 elif (operator == "/"): answer = num1 / num2 / num3 print ("Here is the Answer:", answer) Exercise 4 #1 N=int(input("Enter the side of the square: ")) Area=N*N Perimeter=4*N print(Area) print(Perimeter) #2 FN = input("Type your First Name : ") LN = input("Type your Last Name : ") print ("Hello, " + FN + " " + LN) #3 str = input("Enter a string: ") print("Length of the input string is:", len(str)) #4 print("Input lengths of the triangle sides: ") x = int(input("x: ")) y = int(input("y: ")) z = int(input("z: ")) if x == y == z: print("Equilateral triangle") elif x==y or y==z or z==x: print("Obtuse/Scalene triangle") else: print("Scalene triangle") #5 days = int(input("Please enter days:")) seconds = days * 24 * 60 * 60 print(seconds, " Seconds") #6 num1 = float(input("Enter first number: ")) num2 = float(input("Enter second number: ")) num3 = float(input("Enter third number: ")) if (num1 >= num2) and (num1 >= num3): largest = num1 elif (num2 >= num1) and (num2 >= num3): largest = num2 else: largest = num3 print("The largest number is", largest) #9 numberOfWordsInList = int(input("Enter number of words to be List: ")) def longestWordInList(numberOfWordsInListt): createdList = [input("Enter any word: ") for i in range(numberOfWordsInList)] lengthOfItems = [(len(items), items) for items in createdList] return max(lengthOfItems) print(longestWordInList(numberOfWordsInList))
1