def find_first_occurrence(msg: str, string_to_find: str) -> int: *"Return the index of the first occurence of string to find in msg, or -1 if it does not occur, ignoring case. >» find_first_occurrence('October holidays: Halloween Thanksgiving', 'H') 8. >>> find_first_occurrence('Because DEC 25 == OCT 31', 'H') -1 >> find first_occurrence('hip hip hooray', 'ip')
Q: #include using namespace std; int BinSearch(int arr[],int beg, int end, int key){ if(beg >…
A: Program after removing function #include<iostream>#include<stdlib.h>using namespace…
Q: cout « even_elements(a, 2) <« endl; cout « "Expected: 1" « endl; int b[][COLS] = {{ 3, 1, 4 }, { 4,…
A: Solution :
Q: 1- def getLongestSeq(a, n): maxIdx = 0 maxLen = 0 currlen = e currIdx = 0 for k in range(n): if a[k]…
A: In the above code only one loop is used to find the longest negative consecutive subsequence. In…
Q: #define index OXC2 #define count O×C5 MOVLW .5 CLRF index CLRF count floop: INCF index,1,1 ADDWF…
A: Lets see the solution.
Q: def most_total(bdm): '''(dict of {str: dict of {int: list of str}}) -> str bdm is a birthday month…
A: Given: def most_total(bdm): '''(dict of {str: dict of {int: list of str}}) -> str bdm is a…
Q: e Capital Quiz Problem Write a program that creates a dictionary containing the U.S. states as keys,…
A: Required: Capital Quiz use python The Capital Quiz Problem Write a program that creates a dictionary…
Q: Function f(lst) { return lst.isEmpty() ? lst : node(lst.head (), f(lst.tail())); Function…
A: The above question is the implementation of the sampling of data . in which the head() and the…
Q: Reverse Phone Lookup (Part 2) You have been asked to write a function that supplies the "reverse…
A: def reverse_lookup_dictionary(phone_num, phone_to_name): if phone_num in phone_to_name: return…
Q: Write a function called dict_intersect that takes two dictionaries as arguments and returns a…
A: def dict_interest(dict1, dict2):""" (dict, dict) -> dictReturn a new dictionary that contains…
Q: C++ Code /////// #include class BTNode { public: int item; BTNode *left; BTNode *right;…
A: CODE: // Function to create a new binary tree node having given key BTNode* newBTNode(int key) {…
Q: PART 1 - Complete the function below to deocompose # a compound formula written as a string…
A: Hi there, Please find your solution below, I hope you would find my solution useful and helpful.…
Q: Fix the errors in the procedure below. def BMIImperial(height, weight, bmiList, Category): i=0…
A: Given program contain indentation errors. This can be eliminated by correctly indent the line of…
Q: oks My library > IT 140: Introduction to Scripting v3 home > 2.3: Dictionary basics 8 zyBooks…
A: Algorithm: Start Initialize a dictionary with given data Print the dictionary Add new items to the…
Q: q.utoronto.ca/courses/249645/assignments/834167 We have provided two poetry form description files,…
A: Program: from typing import List, Tuple, Dict def common_prefix(s1: str, s2: str) -> str:…
Q: Complete the below function in Java String deleteAtlndex(String abc, int a ){ //Delete a specific…
A: Required:- Complete the below function in Java String deleteAtlndex(String abc, int a ) {…
Q: tried this code provided from an expert but for some reason, nothing is being shown on the console…
A: Required: I tried this code provided from an expert but for some reason, nothing is being shown on…
Q: function carLambda = [rank, &price] ()->int { cout name); model Car::carModel; auto testLambdaPtr =…
A: In C++ programming, memory allocation for a given program, happens based on what kind of data we are…
Q: please rewrite down code using for loop without iterator
A: Below is the required code where for loop is used without iterator:
Q: strcmp is not working line 49 fix strcmp #include //including headers #include struct…
A: You forgot to include #include <string.h>
Q: Incoroporate or use below code as reference #include #include #include typedef struct…
A: *As per the company norms and guidelines we are providing first question answer only please repost…
Q: omplete hat represents veight. 1ou must impi which supports comparing terms by three different…
A: import java.util.*;import java.lang.*;import java.util.Comparator; public class Term implements…
Q: Question: Consider a hash table to size 10. Write a program by using quadratic probing and insert…
A: Quadratic Probing: Quadratic probing is an open-addressing scheme where we look for the i2‘th slot…
Q: def order_meal(m_to_t: Dict[str, List[int]], meal: str, table: int) -> None: """Modify…
A: def order_meal(m_to_t,meal ,table): if meal in m_to_t.keys(): l=m_to_t[meal]…
Q: Please add file handling to this given C++ code below so that it can store the input of the user:
A: #include<iostream>#include<fstream>#include<cctype>#include<sstream>#include…
Q: Problem statement def stringMatch(subStr,strLine): """ This function returns the index…
A: Programming Language: Python def stringMatch(subStr,strLine): if subStr in strLine: #checking…
Q: def flight_sequences_overlap(path1: List[str], path2: List[str]) -> bool: """Return True iff flight…
A:
Q: Part 2 • Create a dictionary with at least five key-value pairs. Use strings for either the keys,…
A: Complete answer in Python Programming language is given below using dictionary.
Q: Write a function named dictMax which takes two arguments: a dictionary and a list. Your function…
A: Initialize the return value to None and in the initial value we simply update None with our…
Q: Write a function and test that creates a dictionary containing the Canadian provinces and…
A: The program is written in Python. Check the program screenshot for the correct indentation. Please…
Q: #include #include typedef struct PersonStruct { char firstName[15]; char middleName [15]; char…
A: Please upvote. I am providing you the correct answer below.
Q: def longest_unique_substring(s: str) -> str: Given a string , return the longest unique substring…
A: def longest_unique_substring(s:str)->str: longest=0 longestSubStr=s[0] i=0…
Q: Q# Describe what a data structure is for a char**? (e.g. char** argv) Group of answer choices A. It…
A: char is used to represent character and * is to represent a pointer
Q: Please complete the ADT SortedList by finishing all the constructors and methods in the class…
A: -> Sorted list can be defined as the list which is kept sorted. -> Many methods can be used…
Q: Implement a function to insert a node into a binary search tree. Using the following class and…
A: #include <bits/stdc++.h>using namespace std;class TreeNode{ public: int val;…
Q: Write a prgram that creates a dictionary containing course numbers and room numbers of the room…
A: Create 3 dictionary to store, course numbers and room numbers of the room where the courses meet.…
Q: Assume, you have been given a dictionary where the keys present the name of the father and the value…
A: Find the children Find the children of their children
Q: get_total_cases() takes the a 2D-list (similar to database) and an integer x from this set {0, 1, 2}…
A: Coded using Python 3.
Q: Make the Undo and Redo Functions void functions but keep them as they are.
A: So the thing is the code for undo redo and print are already completed sample output:- MyCommand…
Q: Recamán's sequence def recaman_item(n): Compute and return the n:th term of the Recamán's…
A: Actually, python is a easiest programming language. It is a dynamically programming language.
Q: def all_lines_rhyme(poem_lines: POEM, lines_to_check: List[int], word to_phonemes:…
A: Task : Define the function all_lines_rhyme to check the poem lines at given lines_to_check index.…
Q: Complete the doctring. def average_daily_temp(high_temps: List[int],…
A: The objective is to complete the doctring.
Q: Assume, you have been given a dictionary where the keys present the name of the father and the value…
A: Coded using Python 3.
Q: Please complete on Python Write a program that keeps a dictionary in which both keys and values…
A: Algorithm: Start Initialize a dictionary Prompt user to add/remove/modify/print/exit If user…
Q: The function to be built, amino_acids, must return a list of a tuple and an integer when given a…
A: Here is the code for the above problem
Q: Compute and return the first n terms of the Recamán's sequence, starting from the term a1 = 1. Note…
A: Actually, program is an executable software that runs on a computer.
Q: is Valid Phone Number(): ReturnsTrue if the provided phone number (represented as a string) is…
A: Actually, python is a easiest programming language. It has a concise(less) code.
Q: def average_daily_temp(high_temps: list[int], low_temps: list[int]) -> list[float]: """high_temps…
A: According to the Question below the Solution: Output:
Q: Complete the below function which takes a dictionary d and a key k as arguments and returns a value…
A: Algorithm: Let d is a dictionary and k is the key in d. 1. If k is not a key of d, then return None.…
Q: rite a function named build_dict() that will take a string and an index as parameters. The function…
A: Write a function named build_dict() that will take a string and an index as parameters. The function…
Q: program Linked List: modify the following program to make a node containing data values of int,…
A: Actually, c++ is a powerful general programming language.
Step by step
Solved in 4 steps with 2 images
- Old-fashioned photographs from the nineteenth century are not quite black and white and not quite color, but seem to have shades of gray, brown, and blue. This effect is known as sepia, as shown in the figures below. Original Sepia Original Image & Sepia Image Write and test a function named sepia that converts a color image to sepia. This function should first call grayscale to convert the color image to grayscale. A code segment for transforming the grayscale values to achieve a sepia effect follows.Note that the value for green does not change. (red, green, blue) = image.getPixel(x, y)if red < 63: red = int(red * 1.1) blue = int(blue * 0.9)elif red < 192: red = int(red * 1.15) blue = int(blue * 0.85)else: red = min(int(red * 1.08), 255) blue = int(blue * 0.93) 1.GUI Test Generate sepia image 2.Convert gif to png 3.Image Test Image has been converted to sepiaA prime number is an integer value that is only divisible by 1 and itself. 2, 3, 5, 7, and 11 are examples of prime numbers. You have been provided with two function definitions: The is_prime () function takes an integer parameter number, and returns True if number is prime and False otherwise. The get_next_prime () function also takes a single integer parameter number, and returns the first prime number larger than it. You must not change the implementation of these 2 functions. Complete the get_primes_list() function that takes a single list of integers called numbers as parameter. You can assume that the integer items in this list will be non-negative. The function must update this list so that items that are not prime numbers are updated to the first prime number larger than them. To implement this function you must call both the is_prime () and get_next_prime () functions. Some examples of the function being called are shown below. Note: the get_primes_list() function does not…Question 16 Code a JavaScript function called isLeapYear() that accepts one integer value as its parameter and will return true if this value is a leap year and false if it is not. Rules: A leap year is divisible by four but not divisible by 100 unless it is divisible by 400. E.g. 1600, 1912, 1996, 2000, 2020 and 2124 are leap years where 1000 and 3000 are not
- Create a function that returns which chapter is nearest to the page you're on. If two chapters are equidistant, return the chapter with the higher page number. Examples nearestChapter({ "Chapter 1" : 1, "Chapter 2" : 15, "Chapter 3" : 37 }, 10) "Chapter 2" nearestChapter({ "New Beginnings": 1, "Strange Developments" : 62, "The End?" : 194, "The True Ending": 460 }, 200) → "The End?"Create a function named fnTuition that calculates the tuition for a student. This function accepts one parameter, the student ID, and it calls the fnStudentUnits function that you created in task 2. The tuition value for the student calculated according to the following pseudocode: if (student does not exist) or (student units = 0) tuition = 0 else if (student units >= 9) tuition = (full time cost) + (student units) * (per unit cost) else tuition = (part time cost) + (student units) * (per unit cost) Retrieve values of FullTimeCost, PartTimeCost, and PerUnitCost from table Tuition. If there is no student with the ID passed to the function, the function should return -1. Code two tests: 1) a student who has < 9 student units, and 2) for a student who has >= 9 student units. For each test, display StudentID and the result returned by the function. Also, run supportive SELECT query or queries that prove the results to be correct.In this coding challenge, you will be retrieving email usernames from a string. You will write a function named get_usernames () that takes in a string as it's input parameter, and returns a list of email usernames in the string. The input strings will contain 0 or more emails in the format and the '@' symbol will only appear in the context of an email. The order of usernames should match the order in the input text. username@domainname, For example: EXAMPLE 1 text: "If you need help on an assignment, email help@ucsd.edu or support@gmail.com" return: ['help', 'support'] EXAMPLE 2 text: "Good morning! I hope you're having a great time with CSE 8A!" return: [] EXAMPLE 3 text: "I've been having a lot of trouble reaching you, can you please email me at cse@ucsd.edu? return: ['cse', 'cse'] Here is the problem description: Function Name: get_usernames Parameter: text - A string corresponding to a piece of text containing 0 or more emails. Return: A list of the email usernames in the input…
- In python, Old-fashioned photographs from the nineteenth century are not quite black and white and not quite color, but seem to have shades of gray, brown, and blue. This effect is known as sepia, as shown in the figures below. Original Sepia Original Image & Sepia Image Write and test a function named sepia that converts a color image to sepia. This function should first call grayscale to convert the color image to grayscale. A code segment for transforming the grayscale values to achieve a sepia effect follows.Note that the value for green does not change. (red, green, blue) = image.getPixel(x, y)if red < 63: red = int(red * 1.1) blue = int(blue * 0.9)elif red < 192: red = int(red * 1.15) blue = int(blue * 0.85)else: red = min(int(red * 1.08), 255) blue = int(blue * 0. 1. GUI TEST 2. CUSTOM TEST 3. IMAGE TESTCreate a function that takes a variable number of arguments, each argument representing the number of items in a group. The function should return the number of permutations (combinations) of choices you would have if you selected one item from each group. Examples combinations (2, 3) 6 → combinations (3, 7, 4) → 84 combinations (2, 3, 4, 5) → 120Write a function, named randomPassword, that generates a random password that takes no parameter. It will return the randomly generated password as its ONLY result. Display the randomly generated password in the main program. Password Criteria: o The password should have a random length of between 7 and 10 characters. o Each character should be randomly selected from positions 33 to 126 from the ASCII table You must import randint function directly and inline within the random package and it must be the first line of code in your program, after your program header comment. o Declaring and using FOUR constants. Constants must be named appropriately and intuitively. o You must use the chr built-in function within your randomPassword function: o Declaring the main function and invoking randomPassword function. o Logical approach to problem solving, computation, and displaying appropriate output.
- Exercise 3 Take in numbers about 4 times and create a function that adds those four numbers together. Use that sum to check if it is higher than 50 or less than 50. If it is less than 50 tell the user to go work more. If it is more than 50 tell the user good job! They will have good luck for the new year. If it is 50 tell the user to have a good day. # Take in numbers about 4 times and create a function that adds those four numbers together. # Use that sum to check if it is higher than 50 or less than 50. # If it is less than 50 tell the user to go work more. # If it is more than 50 tell the user good job! They wilL have good luck for the new year. # If it is 50 tell the user to have a good day.Phython: Create a function so that when giving you a month it tells you the season of that month, for example: if it is January it will be winter.Using the def, try and except ValueError functions.• Prints on the screen your name, your student ID and your section number. For example, if your name is "xxx yyy",your ID is 42364 and your section is F2, the main function should print "ID_42364_xxx_yyy_section_F2" • Initializes a variable Y with your student ID. if your ID is 42364, the value of Y will be 42364. • Using a FOR loop, prompt the user to enter the salary of Y employees. ulates and prints the average salary of all employees with salary greater than 1100.