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
- Modify songVerse to play "The Name Game" (OxfordDictionaries.com), by replacing "(Name)" with userName but without the first letter. Ex: If userName = "Kaitlin" and songVerse = "Banana-fana fo-f(Name)!", the program prints: Banana-fana fo-faitlin! Ex: If userName = "Kaitlin" and songVerse = "Fee fi mo-m(Name)", the program prints: Fee fi mo-maitlin Note: You may assume songVerse will always contain the substring "(Name)".How to fix this code to work... from tkinter import *from tkinter import ttkfrom tkinter import messagebox class Student: def __init__(self, id, fn, ln, dob, m='undefined'): self.id = id self.firstName = fn self.lastName = ln self.dateOfBirth = dob self.major = m list_of_student = []window = Tk()window.geometry("800x750")window.title("Simple Student Management System")list_of_students = []id = 1001 def add_student(): global list_of_students global id if FirstnameEntry.get() =='': messagebox.showerror('erorr', "First name is required") return if LastnameEntry.get() =='': messagebox.showerror('erorr', "Last name is required") return if DateofbirthEntry.get() =='': messagebox.showerror('erorr', "Date of Birth is required") return if MajorEntry.get() =='': instance = Student(id, FirstnameEntry.get(), LastnameEntry.get(), DateofbirthEntry.get()) else: instance = Student(id, FirstnameEntry.get(), LastnameEntry.get(),…what should I add to make it reject a number? and ask the user to not enter a number by displaying "Syllable must only contain letters or a wildcard" def add_gibberish(word, gib1, gib2):vowels = "AaEeIiOoUu"flag = Truelast = Falsei = 0while (i < len(word)): #traverse whole wordif word[i] in vowels: # if character in a word is vowelif last == False: # if last charcater was not vowelif flag == True: #check if first occurence of vowelword = word[0:i] + gib1 + word[i:len(word)] #add gibberish to the wordi = i + len(gib1) + 1flag = Falselast = Trueelse:word = word[0:i] + gib2 + word[i:len(word)] # if other than first occurence of voweli = i + len(gib2) + 1last = Trueelse:i = i + 1else: # if character is not vowellast = False # set last character was not voweli = i + 1; return word def start():gib1 = input("Enter first gibberish syllable: ")gib2 = input("Enter second gibberish syllable: ")word = input("Enter a word to translate: ")new_word = add_gibberish(word, gib1,…
- please help debuging... // Fix the bugs so that the report of 5 students grades// is correct. There should be no memory leaks.#include <stdio.h>#include <string.h>#include <stdlib.h>#include <assert.h> typedef struct student{ int grade; char* nameID;}student_t; void CreateStudent(student_t* s, int grade, char* nameID){ s->grade = grade; s->nameID = strdup(nameID); } //float ComputeAverageGrade(student_t* class, int sizeOfClass){ assert(sizeOfClass > 0 && "Must have at least 1 student"); float total=0.0f; for(int i=0; i <= 5; i++){ total+= class[i].grade; } return total / sizeOfClass;} int main(){ // Create our classroom of 5 students student_t* class = (student_t*)malloc(sizeof(student_t)*5); for(int i=0; i <5 ; i++){ // Assume all nameID's are "temporary" CreateStudent(&class[i],90,"temporary"); } // Storage for students grades float averageGrade =…Please run this on linux, compile and look at the placement for row "Tangent". Match the numbers below tangent and make sure all the other row numbers are lining up with the other headings main.c #include <stdio.h>#include <math.h> #define M_PI 3.14159265358979323846 /** * Given a incrementVal value, this function will print a table of trigonometric values * from 0 to 360, in increments of the incrementVal value. * For example, if the incrementVal value is 90, the table will print values for 0, 90, 180, 270 and 360. * incrementVal - the degree value to use for the increment*/void displayTriTab(int incrementVal) { //Display the header for the table printf("\n\t--- TRIGONOMETRIC TABLE ---\n\n"); // Display the column headings for the table printf("%3s%10s%10s%10s%10s\n", "Degrees", "Radians", "sine", "cosine", "tangent"); printf("%3s%10s%10s%10s%10s\n", "-------", "-------", "------", "-------", "-------"); //Declare variables for radians, sine cosine,…instructions are in photo and links in photos has code which I have pasted to make it easy to copy. Below is my professor code for Sudoku #2, please make a different version of this code with the same functions as i can not use my teacher's code Sudoku #2 code import java.util.*;import java.io.*; public class MySudokuBoard {public final int SIZE = 9;protected char[][] myBoard;public MySudokuBoard(String theFile) {myBoard = new char[SIZE][SIZE];try {Scanner file = new Scanner(new File(theFile));for(int row = 0; row < SIZE; row++) {String theLine = file.nextLine();for(int col = 0; col < theLine.length(); col++) {myBoard[row][col] = theLine.charAt(col);}}} catch(Exception e) {System.out.println("Something went wrong :(");e.printStackTrace();}}public boolean isSolved() {if(!isValid())return false;Map<Character,Integer> map = new HashMap<>();for(char[] row : myBoard) {for(char cell : row) {if(map.containsKey(cell))map.put(cell, map.get(cell) + 1);elsemap.put(cell, 1);}}//…
- please fix my code from tkinter import * class TicTacToe:def __init__(self, root, b, states):self.root = Tk()self.b = [[0,0,0],[0,0,0],[0,0,0]]self.states = [[0,0,0],[0,0,0],[0,0,0]]for i in range(3):for j in range(3):self.b[i][j] = Button(font=('Verdana', 56), width=3, bg='yellow',command = lambda r=i,c=j: self.callback(r,c))self.b[i][j].grid(row = i, column = j)self.player = 'X'self.stop_game = Falsemainloop() def check_for_winner(self):for i in range(3):if self.states[i][0]==self.states[i][1]==self.states[i][2]!=0:self.b[i][0].configure(bg='grey')self.b[i][1].configure(bg='grey')self.b[i][2].configure(bg='grey')self.stop_game = True for i in range(3):if self.states[0][i]==self.states[1][i]==self.states[2][i]!=0:self.b[0][i].configure(bg='grey')self.b[1][i].configure(bg='grey')self.b[2][i].configure(bg='grey')self.stop_game = True if…Here is the code i am working with, around the last line it says what i need to do, any help please! import java.util.*; import java.io.*; public class FileLoader implements Getter { String [][] data; String [] head; String FILENAME = "wv-covid-daily.csv"; String DELIMITER = ","; int MAX_ROW; int MAX_COL; int dataRows; boolean stillLoading; public FileLoader () { MAX_ROW = 100; MAX_COL = 50; dataRows = 0; data = new String[MAX_ROW][MAX_COL]; head = new String[MAX_COL]; stillLoading = false; } public int getNumRows() { return dataRows; } public String [] getRow (int row) { return data[row]; } public boolean isLoading () { return stillLoading; } public void run () { stillLoading = true; dataRows = 0; try { String line; int row = 0; BufferedReader reader = new BufferedReader(new FileReader(FILENAME)); if((line=reader.readLine())!=null){ String fields[] = line.split(DELIMITER); head=fields; } while((line=reader.readLine())!=null){ String fields[] = line.split(DELIMITER);…Can you please clean up my code? Because i think there is an implementation problem in the middle. Thank you. I have attached the airportqueuedata.txt as a screenshot. #include <iostream> #include <fstream> #include <string> using namespace std; void enqQ(int&); void deqQ(int&); void clearQ(int&, int&); bool isEmpty(int, int); bool isFull(int, int); struct planes // data type plane declared via struct { stringrequest; stringflightNum; stringstartingPoint; stringdestination; stringnumberOfPassengers; }; void enqQ(int& rear) // adds data to queue { rear = (rear + 1) % 10; } void deqQ(int& front) // delets data from queue { front = (front + 1) % 10; } void clearQ(int& front, int& rear) // clears queue { front = -1; rear = -1; } bool isEmpty(int front, int rear) // tells if queue is empty or not { if (rear == front) return true; else return false; } bool isFull(int front, int rear) // tells if queue is full or not { if…
- Modify songVerse to play "The Name Game" (see OxfordDictionaries.com), by replacing "(Name)" with userName but without the first letter.Ex: If userName = "Kaitlin" and songVerse = "Banana-fana fo-f(Name)!", the program prints:Banana-fana fo-faitlin! Ex: If userName = "Kaitlin" and songVerse = "Fee fi mo-m(Name)", the program prints:Fee fi mo-maitlin Note: You may assume songVerse will always contain the substring "(Name)". *Please write this code in C++*I need some helping fixing my code for this method(in screenshot). Also could you explain tokens please! public static double[][] readFile (java.io.File file) throws FileNotFoundException{ String[] temp = new String[10]; int row = 0; int colum = 0; int i = 0; int k = 0; double[][] Fill = null; Scanner sc; try { sc = new Scanner(file); String[] token; while(sc.hasNextLine()){ temp[row] = sc.nextLine(); //split = line.split(" "); row++; } Fill = new double[row][]; for(; i<row; i++){ token = temp[i].split(" "); colum = token.length; Fill[i] =new double[colum]; for(; k<token.length; k++) { Fill[i][k]=Double.parseDouble(token[k]); } k = 0; i++; } sc.close(); for(int p = 0; p<Fill.length;p++) { for(int v =0; v<Fill[colum].length; v++) { System.out.println(Fill[row][colum]+ " "); } System.out.println(); } }catch( FileNotFoundException e) { e.getMessage(); } return Fill; } }Please fix the code below to make it faster def countInBox(particleData, steps, lx, ly, ux, uy):for _ in range(steps):for i in range(len(particleData)):nx, ny= particleData[i][2]/particleData[i][3], particleData[i][4]/particleData[i][5]x, y = particleData[i][0], particleData[i][1]particleData[i][0] = nx * x - ny * yparticleData[i][1] = ny * x + nx * yreturn sum([1 for i in range(len(particleData)) if(lx < particleData[i][0] < ux and ly < particleData[i][1] < uy)])