Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Help with writing this python code please. short explanations if possible, thanks. 1. Write a function compare (s1,s2) that takes as inputs two string values
Help with writing this python code please. short explanations if possible, thanks.
1. Write a function compare (s1,s2) that takes as inputs two string values s1 and s2, and that returns the string that comes later in the dictionary (i.e., the string that is greater according to the > operator). For example: > compare ('program', 'code') \#'program' > 'code' result: 'program' 2. Write a function combine (s1,s2,n) that takes as inputs two strings s1 and s2 and an integer n, and that returns a new string in which the last n characters of s1 are followed by the first n characters of s2. For example: > combine('computer', 'science', 3) result: 'tersci' >> combine ('python', 'code', 2) result: 'onco' If either string (s1 or s ) does not have at least n characters, you should use all of its characters: > combine('amazing', 'you', 4) result: 'zingyou' 3. Write a function reverse_n(vals, n ) that takes as inputs a list vals and an integer n, and that constructs and returns a new list in which the first n values of vals are reversed and all other values from vals remain in their original positions. For example: result: [3,2,1,4,5,6]# reversed the first 3 valuesStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started