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))
Subscribe to:
Post Comments (Atom)
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...
-
EXAM PREPARATION PDF PART 1 ABOUT THE COURSE : A fun filled whirlwind tour of 30 hrs, covering everything you need to know to fall in love w...
-
Exam Preparation PDF ABOUT THE COURSE : Industry 4.0 concerns the transformation of industrial processes through the integration of modern...
-
Exam Preparation PDF ABOUT THE COURSE : With the increased availability of data from varied sources there has been increasing attention paid...
No comments:
Post a Comment