def is square(num: int) -> bool: Returns True if is a perfect square. That is, whether there exists an integer 'i' such that i*i is equal to . You may only use arithmetic operations and comparison statements. This means you are NOT allowed to use any of [if, and, or]. You can, however, use built-in functions like round (), etc. Precondition: num >= O
Q: Overload all relational operators (, =, ==, and !=) for Distance class. A sample output is given…
A: The answer is
Q: Write function is decompose. First you reduce the fraction. Then you return a Fraction that is one…
A: SUMMARY: - Hence, we got the output.
Q: Assume that N is a positive integer. Returns the sum from 1 to N inclusive, but omitting the numbers…
A: According to the provided information: We need to create a python program that calculates the sum…
Q: Champernowne word
A: def counting_series(n):len = 1;count = 9;start = 1; #Finding the length of the number from where the…
Q: Consider the following function shoots: def shoots(x: int) -> int: 2 if x <= 0: 3\ return 0 4 elif x…
A: We are given a recursive function and we are given few statements for it, we need to pick the…
Q: Lion king from the jungles of Hakuna Matata likes random numbers. Let F4(X) be the number of digits…
A: Given Data:
Q: Please type so I can copy paste*** Exercise 1.6.2: Truth values for quantified statements about…
A: (d) ∀x (x2-x ≠0) The statement indicates that for all x (set of integers) difference of the square…
Q: Q1: Complete the following program by writing its functions: static void Main(....) { } 10, 12, 7,…
A: Power(a[1], a[2], ref p); This function is wrong as a is an integer and not an array. So we cannot…
Q: What is wrong with the following function? int 3integer_add(int x,int y,int x)
A: A function is a block of code that performs a specific task. A function exchange information by…
Q: Recall the simple calculator program shown in class, which had ADD, SUBTRACT, MULTIPLY and DIVIDE…
A: The operator can be defined as a symbol which is responsible for a particular operation between two…
Q: Here is a function prototype: int getTotal(int, double, string); Which of these prototypes would…
A: Method Overloading is a feature that allows a class to have more than one method having the same…
Q: Implement the plus_one function as directed in the comment above the function. If the directions are…
A: We can get Sum of two number by performing XOR ( ^ ) and the carry bit by using AND ( & ).Here…
Q: write pyhton code with indentation and alternative solution for; Write a function called…
A: def reverse_only_letters(argument): string = [] #convert the given string to list as it is…
Q: Write in Java: Write a program that takes in a positive integer as input, and outputs a string of…
A: Programming Approach: Importing necessary package Declaring main class Defining the main method…
Q: What is the Following code doing? for y in range(img.getHeight(): for x in range(img.getWidth()): p…
A: I have Provided this answer with full description in step-2.
Q: Consider the following function: int secret(int m, int n) { int temp = n; for (int i = 1; i <…
A: Explanation: i) cout << secret(5, 4) << endl; The operations involved in the above…
Q: def myfun ( x: Int, if x 0)': string) : String - { y + x, toString } else { myfun( x - 2 , "world" )…
A: Here we write answer of all the 6 Question marks:…
Q: (Algebra: solve 2 X 2 linear equations) You can use Cramer's rule to solve the following 2 x 2…
A: // Cramer.java /* * This Program will calculate x and y for two linear equations using Cramers rule…
Q: What does the function return for any positive values of x and n ? The answer should be a general…
A: #include <iostream>using namespace std; int what_do_I_do(int x, int n){ if (n == 1)…
Q: Given an alphabet, print all the alphabets up to and including the given alphabet. Write a…
A: I have added the output screenshots for better understanding. Example one shows the output when we…
Q: Look at the differences between max1 and max2 2. What is the difference? 3. Do the two functions do…
A: Dear Student, In C language 2D arrays are stored in the memory continuously in the row major order…
Q: int RFunc(int a, int b) { if (a <= 0 || b <= 0) { return a+b; } else { return RFunc (a-1, b-1) +…
A: HERE IS STEP BY COMPLETE SOLUTION REGARDING YOUR PROBLEM
Q: Consider the function, f(n), defined by the following code int f(int n) { int r = 0; if (…
A: This question is related to time complexity in algorithm and we have to calculate the time…
Q: def counting_serien (n) The Champernowne word 1234567891011121314151617181920212223. is an…
A: Required:
Q: Suppose we have the function f(n) = (n+1)3. Below are a number of statements regarding how the…
A: We are given function f(n) = (n+1)3. And we are asked that how the feature grows depending on n for…
Q: void foo(int n) { } int i; for (i = 0; i 0) i = 1 / 2;
A:
Q: What does this function do? def f2(s): i=len(s)-1 while(i>=0): print(s[i],end="") i=i-1 A It prints…
A: The correct option is option A. The given function prints the reverse of passed parameter s.…
Q: please code in python Find the Error The following function takes in a positive integer and returns…
A: logic:- In the above function , at first time only if condition fails else condition is returning…
Q: Trace the following code and write what it does. void Finals(X, Y, m, n) int i1, ju1, k1; while (i…
A: We are given the following code and we need to trace what it does. void Finals(X, Y, m, n){ int…
Q: This is a JAVA programming assignment. Program a Genetic Algorithm to find an integer number between…
A: int select (int popsize, double sumfitness,pouplation pop) { partSum=0; rand= Random*sumfitness;…
Q: Note that you may not use any string methods (e.g., replace, find, index, etc.) when writing the…
A: According to the information given:- Enter a string :Python is the best Programming Language.Enter…
Q: Write a function check_vowels() that gets a string as a parameter and check if every vowel is…
A: Required:
Q: Does this function work? For example: $16.65 has 66 quarters, 1 dime, 1 nickel, and 0 pennies. If…
A: The given function does not work properly. For example, $16.65, prints 66 quarters, 1 dime, 0…
Q: Write in Java. Given an alphabet, print all the alphabets up to and including the given alphabet.…
A: import java.util.*;public class Main{ static void printAlphabet(char ch) {…
Q: The following words have three consecutive letters that are also consecutive letters in the…
A: Create a java Class StringSlicerCreate methods fillList and displayList in StringSlicer classIn main…
Q: The following is a implementation of the Ackermann function: public static long Ackermann(int m, int…
A: Ackermann Function: The Ackermann function is the simplest example of a well-defined total function…
Q: Fill in the blank in the function below such that the function takes in two Card objects and returns…
A: You need to write card_one.suit == card_two.suit where card_one and card_two are the class objects…
Q: (Prime Testing) A positive integer n is prime if it is greater than or equal to two and it is evenly…
A: Prime number: A number is said to be prime if the number has two factors, called one and itself.…
Q: Consider the following C++ function. int mystery(int num1, int num2){if (num1 > 0){for (int i =…
A: C++ Program: #include<iostream> using namespace std; int mystery(int num1, int num2) { if(num1…
Q: Write a function called has_duplicates that takes a string parameter and returns True if the string…
A: alphabet="abcdefghijklmnopqrstuvwxyz" test_dups =…
Q: Write a generator expression G that produces the sequence of positive integers k in the range 1 < k…
A: Actually, python is a easiest programming language. It is a dynamically typed programming language.…
Q: Program in python There is function F. Give an integern (n 2 2), consider the prime factorization n…
A: I have done this program myself. As you can see in the problem value of 125 largest prime factor is…
Q: are given a non-negative number x, the decimal portrayal of which contains n digits. You need to…
A: Here have to determine about python programming language code for red - black letter.
Q: Write a function “gcDivisor” that takes two positive int “k” and “m” and returns the greatest common…
A: A call is made to a function called gcd with the numerator and denominator after receiving the user…
Q: /* Write a function `coinProblem` that takes * 3 arguments: N, M and K; and solves following *…
A: PROGRAM EXPLANATION: Include the header file. Define a function coin problem(), this function will…
Q: int snakes[100] = {0}; int ladders[100] = {0}; snakes[31] = 11;…
A: C++ programming language is an object-oriented programming language, that's a cross-platform…
Q: Write a function check_vowels() that gets a string as a parameter and check if every vowel is…
A:
Q: The Champernowne word 1234567891011121314151617181920212223... is an infinitely long string of…
A: Implemented with the hint provided in the question. Its a relatively complex one, so I tried…
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 1 images
- using System;using System.Text.RegularExpressions;class chapter8 {static void Main() {string words = "08/14/57 46 02/25/59 45 06/05/85 18" +"03/12/88 16 09/09/90 13";string regExp1 = "(\\s\\d{2}\\s)";MatchCollection matchSet = Regex.Matches(words,regExp1);foreach (Match aMatch in matchSet)Console.WriteLine(aMatch.Groups[0].Captures[0]);}} Now let’s modify this program to search for dates instead of ages, and usea grouping construct to organize the dates. And write the c# code:A Java Practical Assignments.pdf - Adobe Acrobat Pro DC (32-bit) File Edit View E-Sign Window Help Home Tools Java Practical Assig. x Sign In 1 /1 139% Java Practical Assignments 1. Write an application that throws and catches an ArithmeticException when you attempt to take the square root of a negative value. Prompt the user for an input value and try the Math.sqrt() method on it. The application either displays the square root or catches the thrown Exception and displays an appropriate message. 2. Create a program that allows a user to input customer records (ID number, first name, last name, and balance owed) and save each record to a file. 3. Write an application for Limpopo's Car Care Shop that shows a user a list of available services: oil change, tire rotation, battery check, or brake inspection. Allow the user to enter a string that corresponds to one of the options, and display the option and its price as R250, R220, R150, or R50, accordingly. Display an error message if the…Lab Assignment 1: Vigenere Cipher Overview: You are required to implement the Vigenere Cipher using any programming language of your choice. Your program should be able to encrypt any given message written in text. Your program should allow the user to submit a message for encryption (the message must use text only). You should use the following message to demonstrate the encryption: “Party on the Quad." Your program should allow the user to input the key for performing the encryption. Please use the following key to demonstrate the encryption process: "Homecoming."
- Write an application that counts by five from 5 through 500 inclusive, and that starts a new line after every multiple of 50 (50, 100, 150, and so on). public class CountByFives { public static void main (String args[]) { // Write your code here } }Find the body for: def contains_no_lowercase_vowels(phrase: str) -> bool: """Return True iff (if and only if) phrase does not contain any lowercase vowels. >>> contains_no_lowercase_vowels('syzygy') True >>> contains_no_lowercase_vowels('e') False >>> contains_no_lowercase_vowels('abc') False """strobogrammatic number is a number that looks the same when rotated 180 degrees (looked at upside down). Find all strobogrammatic numbers that are of length = n. For example, Given n = 2, return ["11","69","88","96"]. def gen_strobogrammatic(n): Given n, generate all strobogrammatic numbers of length n. :type n: int :rtype: List[str] return helper(n, n) def helper(n, length): if n == 0: return [™"] if n == 1: return ["1", "0", "8"] middles = helper(n-2, length) result = [] for middle in middles: if n != length: result.append("0" + middle + "0") result.append("8" + middle + "8") result.append("1" + middle + "1") result.append("9" + middle + "6") result.append("6" + middle + "9") return result def strobogrammatic_in_range(low, high): :type low: str :type high: str :rtype: int res = count = 0 low_len = len(low) high_len = len(high) for i in range(low_len, high_len + 1): res.extend(helper2(i, i)) for perm in res: if len(perm) == low_len and int(perm) int(high): continue count += 1 return…
- python: numpy def not_stealing(items): """ While you're shopping, you notice that some items you've picked up do not have a price tag. Do you steal them? NO! Instead, you decide to be a good person and replace them with another item that does have a price. - Items with no price will have a value of np.nan. - Replace np.nan values with a random price between $5 and $9, inclusive. - Return the average of the new prices in the array, rounded to 2 decimal places. - DO NOT REMOVE random.seed(1) Args: items (np.array) Returns: float >> items = np.array([4.63, np.nan, 3.78, 7.12, 12.35, 7.19, np.nan, 1.50, 2.41]) >> not_stealing(items) 5.66 """ #DO NOT REMOVE# random.seed(1) ############## # items = np.array([4.63, np.nan, 3.78, 7.12, 12.35, 7.19, np.nan, 1.50, 2.41]) # print(not_stealing(items)) # items = np.array([np.nan, np.nan, 6.18, np.nan, 18.42, 2.67, 9.14, np.nan, 14.32]) #…Load your bag with some initial values, but do not fill it. Your client code should give the user the option to: display the contents of the bag using the class method “toVector” add values to the bag remove values from the bag sort the bag search for a value using their choice of either the iterative search or the recursive search - both need to be tested Allow the user to keep doing these things until they are done. Do not automatically sort the bag if the user chooses to search. Your program should give the user a message telling them they must first sort the bag before they can search.You decide what the user interface will be. Make it clear and easy to use. It can be very basic; nothing fancy. A menu driven program works well. Each value in your array should be unique - no value will appear in the array multiple times. Your array elements can be any data type – use a template class put in place in the code provided. You can write your client code to process a bag holding any…Extreme Fizz BuzzFizz Buzz is a classic Computer Science problem about Selection. For an integer x, print:• “Fizz” if x is only divisible by 3,• “Buzz” if x is only divisible by 5,• “FizzBuzz” if x is divisible by both 3 and 5,• the number x if it is not divisible by both 3 and 5.This problem is the extreme version of Fizz Buzz. You are given a list of K distinct integers A and a list of K characters S. Both lists are numbered from 1 to K. The integer Ai corresponds to the character Si. Denote B as the subset of A. There will be a rule for each possible subset: if an integerx is only divisible by all elements in B, print a string which is the concatenation of the corresponding character of each element in B, sorted by the index in ascending order. However, if B is an empty subset, print the first digit of x instead. Does it look complicated? Do not worry, as it is just a generalization of the regular Fizz Buzz. For example, if A = [3, 5] and S = [F, B], you will get the normal Fizz…
- Part 2 - OddOrEven ClassIn bluej. Write a program that prompts the user to enter an integer. The program should display “The input is odd" to the screen if the input is odd and displays “The input is even" to the screen if the input is even. Hint: Consider using the mod (%) operator.Assignment4B: Diamonds in the sky. In our earliest labs, we asked you to print a diamond pattern to the screen using predefined print statements. Now that we know how to use loops, we can make more dynamic and customizable patterns. For this assignment, we will prompt the user to enter a maximum width for the diamond. If they enter a number less than 3, we'll prompt them to choose a correct width. If they enter an even number (greater than 3), we will add 1 to it and let the user know the final diamond size. Then we will generate and print out the diamond using * and '' symbols. Hints: Each line of the "diamond" is made up of two parts – the asterisks in the center and the spaces to the left of it. The amount of "left space" decreases as we go towards the middle diamond, then increases afterwards as we go towards the bottom. Could we use multiple loops (or even nested loops) to model this behavior? Also, note that the number of asterisks increases (and later decreases) by two on each…File Factorials.java contains a program that calls the factorial method of the MathUtils class to compute the factorials of integers entered by the user. Save these files to your directory and study the code in both, then compile and run Factorials to see how it works. Try several positive integers, then try a negative number. You should find that it works for small positive integers (values < 17), but that it returns a large negative value for larger integers and that it always returns 1 for negative integers. Returning 1 as the factorial of any negative integer is not correct—mathematically, the factorial function is not defined for negative integers. To correct this, you could modify your factorial method to check if the argument is negative, but then what? The method must return a value, and even if it prints an error message, whatever value is returned could be misconstrued. Instead it should throw an exception indicating that something went wrong so it could not complete its…