Which tool is used to execute Python code line-by-line interactively within a terminal?
Fix the indentation error in this function that should return a greeting message.
def greet(name):
return " Hello " + name
What does the string method ' ' .join() return when applied to the list [ ' Hello ' , ' World ' ]?
Complete the function is_positive(number) that returns True if the number is greater than 0, and False otherwise.
def is_positive(number):
# TODO: Return True if number > 0, False otherwise
pass
Complete the function get_second_item(items) that takes a list and returns the second item. Assume the input is always a list containing at least two elements.
For example, get_second_item([10, 20, 30]) should return 20.
def get_second_item(items):
# TODO: Return the second item from the list
pass
Write a complete function convert_temperature(celsius) that converts Celsius to Fahrenheit using the formula: F = C * 9/5 + 32.
For example, convert_temperature(0) should return 32.0.
def convert_temperature(celsius):
# TODO: Convert Celsius to Fahrenheit using F = C * 9/5 + 32
pass
Write a complete function word_count(text) that counts and returns the number of words in the given text. Words are separated by spaces.
For example, word_count( " Hello world Python " ) should return 3.
def word_count(text):
# TODO: Count and return the number of words in text
pass
Complete the function calculate_tip(bill, tip_percent) that calculates and returns the tip amount based on the bill and tip percentage.
For example, calculate_tip(50, 20) should return 10.0.
def calculate_tip(bill, tip_percent):
# TODO: Calculate and return the tip amount
pass