google-site-verification=EmVnnySXehAfTr_j8ZJN48hwvxJtfNf80pkPX1ObQlA Fast Track News: Week 3 The Joy of Computing using Python Assignment 3 Programming ANSWERS

Week 3 The Joy of Computing using Python Assignment 3 Programming ANSWERS

 Week3

Question1: # Sort the marks in ascending order for i in range(len(marks)): for j in range(len(marks) - 1): if marks[j] > marks[j + 1]: marks[j], marks[j + 1] = marks[j + 1], marks[j] # Calculate the median n = len(marks) if n % 2 == 1: median = marks[n // 2] else: median = (marks[n // 2 - 1] + marks[n // 2]) / 2 return median Question2: def sort_string(input_string): # Convert the input string to lowercase input_string = input_string.lower() # Sort the string in alphabetical order sorted_string = ''.join(sorted(input_string)) # Return the sorted string return sorted_string # Example usage input_string = input().rstrip() # Removes any trailing newline character print(sort_string(input_string))

No comments:

Post a Comment

April Week 2 || Lab 2 || Troubleshooting Data Models in Looker

  CREATE NEW FILE NAME: user_order_lifetime view: user_order_lifetime { derived_table: { sql: SELECT order_items.user_id as us...