5. Create a variable “name” whose value is “aYcLogic”. Using Python String built-in functions and above “name” variable, print like the following 3 lines to the shell. You have to use above “name” variable.
Answer
name = "aYcLogic" print(name.title()) print(name.upper()) print(name.lower())
6. Write a program in Python that would ask a name to the user in Python Shell. After the user enters a name, the program will print “Hello
Answer
name = input("What is your name? ") print(f"Hello {name}")
7. Create a Python program to check movie ticket price. Ask user how old are you in the shell? If user enter any number smaller 5 than print they don’t have to pay to watch the movie. If user enter number smaller than 10, they need to pay $5. If user enter number smaller than 60, they have to pay $10. If user enter number 60 or older they have to pay $5.
Answer
age=input("How old are you? ") if int(age) < 5: print("You don't have to pay for the movie") elif int(age) < 10: print("You need to pay $5") elif int(age) < 60: print("You need to pay $10") else: print("You need to pay $5")
8. Create a function, “do_something_cool”, no parameter. When you call the function, it will print “Hip hip hooray” to the shell. Call the function.
Answer
def do_something_cool(): print("Hip hip hooray") do_something_cool()
9. Create a function, “repeat”, with one parameter, “text”. Inside the function, print the value of parameter “text” 5 times to the shell using for loop. Call the function.
Answer
def repeat(text): for count in range(5): print(text) repeat("Gamas")
10. Create a function, “divide”, with 2 parameters, num1 and num2. Inside the function, divide num1 with num2 and print the result to the shell. Call the function and pass 2 numbers as parameters : 12 and 3. The function should print number 4 to the shell.
Answer
def divide(num1,num2): print(num1/num2) divide(12,3)