Leap Year: The earth doesn't take exactly 365 days to revolve around the sun and because of this we have leap years roughly every 4 years to make up the difference. The exact rule is: • Years divisible by 4 are leap years • except if they are also divisible by 100 and then they are not leap years (so 1900 was not a leap year), • unless they are also divisible by 400 and then they ARE leap years (so 2000 was a leap year). Part 1) Write a function in Python that takes as input a number, the year, and determines if it is a leap year or not. The function should return True if it is a leap year and False otherwise. Part 2) Write a main function to test out your leap year function on a few different illustrative inputs.
Q: One day, Fred and his N friends were playing a card game in which each player throws a card with a…
A: Introduction:Here we are given the task of creating a Python system to assist Fred in browsing the…
Q: The annual rate of inflation is the rate at which money loses its value. For example, if the annual…
A: PROGRAM CODE: #include <iostream>#include <iomanip>using namespace std; int main(){…
Q: A perfect number is an integer that is the sum of its positive proper divisors (all divisors except…
A: Use an infinite loop to accept input and break from loop when user inputs STOP
Q: C++ Code Mr. Naughty loves to play with balls. So, his friend, Mr. Nice, gave him n balls to play…
A: Code process The first line contains the same number n - the number of balls. Inext n lines contain…
Q: 2) A BMI Calculator: the body mass index (BMI) is a measure used to determine whether a person is…
A: Java Code import java.util.Scanner; public class Test { public static void main(String[] args) {…
Q: One of the most popular games of chance is considered to be a game of dice, known as "Craps", which…
A: import java.util.Random;public class DiceGame {Â Â public static void main(String[] args) {Â Â Â Â…
Q: 23. A perfect number is a positive integer that is equal to the sum of its positive divisorsexcept…
A: The below given java program will obey the following rubrics:Importing essential header…
Q: After lunch let's go out for a coffee. .9 (after) pronoun O nrenosition
A: A preposition is a word or gathering of words utilized before a noun, pronoun, or noun expression to…
Q: You are given a positive integer x. Check whether the number x is representable as the amount of the…
A: Here have to determine about the sum of cube programming problem statement.
Q: The card game “War” is played by the following rules (you may have learned different rules. Use…
A: def review_to_words( raw_review ): # Function to convert a raw review to a string of words #…
Q: Fibonacci numbers have a lot of numerical properties. A few can be mentioned is that the squares of…
A: Fibonacci numbers have a lot of numerical properties. A few can be mentioned is that the squares of…
Q: palindromic prime is a prime number and also palindromic.For example, 131 is a prime and also a…
A: Program: //Definition for class "Main" public class Main { //Definition for main class public…
Q: (Emirp) An emirp (prime spelled backward) is a nonpalindromic prime number whose reversal is also a…
A: The Java software displays the first 100 emrip numbers, which are nonpalindromic numbers with a…
Q: Square of 13 is 169. 31, which is a reverse of 13 has a square 961. Here are few numbers which have…
A: // Following C Program will give required Output #include <stdio.h>int reverse(int n){…
Q: Make this code more efficient: numb = int(input("What is your favourite number? ")) name =…
A: The input() method reads the value from the input, converts into the string. So there is no need for…
Q: positive integer named N, Get the remainder of N/10 and put it to a Get the integer part of the…
A: Hey there, I am writing the required solution of the questin mentioned above. Please do find the…
Q: When you borrow money to buy a house, a car, or for some other purpose, you repay the loan by making…
A: let us see the answer:- Below I have written the code in c++ iostream: iostream is an abbreviation…
Q: Exercise GradesStatistics (Method): Write a program called GradesStatistics, which reads in n grades…
A: Purpose of the program: This program asks the user to insert grades of multiple subjects into an…
Q: The Penny Pitch game is popular in amusement parks. Pennies are tossed onto a board that has certain…
A: ANSWER:-
Q: A perfect number is a positive integer that is equal to the sum of its positive divi- sors except…
A: code:- function output = perfectNumbers(n)output = zeros(1,n);for i = 1:ntest = 1:i-1;if…
Q: The aim of Part 2 is to set up the puzzle for the player to solve in Part 3.
A: import java.io.*; import java.util.*; public class Main { public static void generateTest(int…
Q: S Q T S Q T (+) P QR S The problem asks to replace each letter with a number between 0 to 9 so that…
A: Given that, SQT (+) SQT = PQRS By adding 2 same three digit numbers, the value must be a…
Q: Description: The Fibonacci numbers are stated as an infinite sequence starting with 0 and 1, which…
A: Main.java package application; import javafx.application.Application;import…
Q: The octal numeral system is a base-eight positional system that uses the symbols 0, 1, 2, 3, 4, 5,…
A: according to our guidelines we are authorized to answer only one question if you want answer of…
Q: Arranging Pebbles Write a program that can arrange a group of pebbles into its designated position.…
A: i give this question answer program with number of integer we describe, first take number of colur…
Q: (Population projection) The U.S. Census Bureau projects population based on thefollowing…
A: Program: //declaring the class public class Population { //defining the main method public…
Q: 3). In a math class you lean about the different operations that can be done to a series. Imagine…
A: //include the required header file #include <iostream> using namespace std; //definition of…
Q: Voltage readings are obtained from an electrical substation once every hour for six hours Write a…
A: The Program language is not mentioned here. So, I am using C language to answer your question. The C…
Q: beginers given real numbers a,b,c, a≠0 Solve the equation 2x+bx+c=o
A: Given: Solve the equation ax^2+bx+c=o The solution for ax^2+bx+c will be x=(-b±b2-4ac )(2*a) So we…
Q: A perfect number is a positive integer that is equal to the sum of its positive divi- sors except…
A: Answer: % Create perfectNum() function function myNum-perfectNum(num) %num=10000 if you want four…
Q: 2.16 LAB: Musical note frequencies On a piano, a key has a frequency, say f0. Each higher key (black…
A: Required: python On a piano, a key has a frequency, say fO. Each higher key (black or white) has a…
Q: n a classroom election, two presidential candidates, namely, Lisa and Teddy, both garnered the same…
A: We are given a situation where two candidates won by equal votes. To decide who will be president…
Q: A nutritionist who works for a fitness club helps members by evaluating their diets. As part of her…
A: Program Approach Make a method to return the total calories from number. Input the Fat Grams.…
Q: a Questions - (Has 2 Parts). Based on each code, which answer out of the choices "A,B,C,D,E" is…
A: The given parts are related to Java packages (in-built) calendar and TimeZone which are used to get…
Q: An Armstrong number is a number such that the sum ! of its digits raised to the third power is equal…
A: As the programming language is not mentioned so I am using C++ language to write a code. Program…
Q: The Mach number is a critical quantity in aerodynamics. It is the ratio of the speed of an object…
A: MATLAB code given below
Q: When you borrow money to buy a house, a car, or for some other purpose, you repay the loan by making…
A: // iostream in C++ is the standard library which implement stream based input/output capabilities…
Q: Write a program that reads 10 numbers and then finds the largest number and prints it and finds the…
A: Programming language is not defined so I am providing program in python. Pseudo code Declare a…
Q: How to attempt? Question : The Card Game One day, Fred and his N friends were playing a card game in…
A: Input Specification: input1: An integer N denoting the number of cards(1<=N<=500) input2: An…
Q: When you borrow money to buy a house, a car, or for some other purposes, then you typically repay it…
A: Actually, program is a executable software that runs on a computer.
Q: GU Computer Engineering Department created a new mathematical game that can be played with two…
A: Given: We have given a problem where two people green and red play a game. There is a list of n…
Q: Frog Contest On their way down the river, Jojo and Lili saw two frogs each in position X1 and X2.…
A: //c++ program #include<iostream> using namespace std; int main(){ int x1,v1,x2,v2,t,f=0;…
Q: A perfect number is a positive integer that is equal to the sum of its positive divi- sors except…
A: Answer :
Q: The Card Game One day, Fred and his N friends were playing a card game in which each player throws a…
A: As per question, we required an algorithm Algorithm: 1. First calculate the total sum of the input…
Q: A perfect number is a positive integer that is equal to the sum of its positive divi- sors except…
A: Required:
Q: Combine the first name, middle name, and last name and assign it as the 'fullname' of the hero. If…
A: Implementing given program in C++.
Q: Medium resistance: This class includes all resistances of values between 10 Q and 100 k Q. Most of…
A: Below is the complete solution and explanation to the given question in detail.
Q: utput Format Print a single line containing the name of month. Be careful about the newline ('\n')…
A: Note: Since you have not provided the language to write the code so I am using Java language to…
Q: complex number
A: import java.lang.Math; //Complex class.public class Complex implements…
Max Function
Statistical function is of many categories. One of them is a MAX function. The MAX function returns the largest value from the list of arguments passed to it. MAX function always ignores the empty cells when performing the calculation.
Power Function
A power function is a type of single-term function. Its definition states that it is a variable containing a base value raised to a constant value acting as an exponent. This variable may also have a coefficient. For instance, the area of a circle can be given as:
Step by step
Solved in 2 steps with 1 images
- Java Assignment: Mathematics is the very interesting subject and for the India it is also a point of pride because Mr. Brahmagupta gives the 0 to world. So, in this series want to be great mathematician like Brahmagupta. He is keep practicing for her goal achievement. Once He knew about the Vector dot Product So He asked his friend Sammer the problem. He gave her two vectors A and B length N. He asked him to reduce the dot output of these two vectors. Sammer has the option to change the order of the objects of these two carriers i.e., in any two objects I and j at any vector can change the shape of these objects. Since Sammer is new to the program, he has asked you to resolve the issue using C++ Programming language. Input: 1 4 142-5 3 -8 5 2 Output: -50Scenario As you surely know, due to some astronomical reasons, years may be leap or common. The former are 366 days long, while the latter are 365 days long. Since the introduction of the Gregorian calendar (in 1582), the following rule is used to determine the kind of year: if the year number isn't divisible by four, it's a common year, otherwise, if the year number isn't divisible by 100, it's a leap year. otherwise, if the year number isn't divisible by 400, it's a common year. otherwise, it's a leap year. none of the above year int(input("enter the year")) if (year%4 1-0) and (year%400 -0) or (year % 1000): print (year is common year") else: print(year, is leap year") year= int(input ("enter the year")) if (years !-0) or (year480 1-0) and (year % 1001-0): print(year is common year") else: print(year, "is leap year") D year= int(input("enter the year"))PYTHON CODE: In order to beat AlphaZero, Grandmaster Hikaru is improving her chess calculation skills.Today, Hikaru took a big chessboard with N rows (numbered 1 through N) and N columns (numbered 1 through N). Let's denote the square in row r and column c of the chessboard by (r,c). Hikaru wants to place some rooks on the chessboard in such a way that the following conditions are satisfied:• Each square of the board contains at most one rook.• There are no four rooks forming a rectangle. Formally, there should not be any four valid integers r1, c1, r2, c2 (≠r2,c1≠c2) such that there are rooks on squares (r1,c1), (r1,c2 (r2,c1)and (r2,c2).• The number of rooks is at least 8N.Help Hikaru find a possible distribution of rooks. If there are multiple solutions, you may find any one. It is guaranteed that under the given constraints, a solution always exists.InputThe first line of the input contains a single integer T denoting the number of test cases. The first and only line of each test…
- Q3: Interplanetary Spaceflight Milan Tusk is the richest person in the universe. After devoting decades of his life to further our space exploration technologies, he’s finally ready to retire. Being a space enthusiast, the first thing he wants to do is visit n planets p1, p2, …, pn, in this order. He’s currently on planet p0. Milan knows that the distance between planets pi and pi + 1 (for 0 ≤ i < n) is d[i]light years. His spaceship uses 1 tonne of fossil fuels per light year. He starts with a full tank and can fill up his tank at any of the n planets (but he must not run out in between two planets). There’s a huge cost to set up the spaceship for refuelling. Due to financial constraints (he’s not THAT rich), he can fill up his tank at most ktimes. In order to save money and make his spaceship lighter, Milan is looking for the smallest possible fuel tank that enables him to complete his space travel and reach planet pn. What is the smallest tank capacity that enables him to do so?…A year in the modern Gregorian Calendar consists of 365 days. In reality, the earth takes longer to rotate around the sun. To account for the difference in time, every 4 years, a leap year takes place. A leap year is when a year has 366 days: An extra day, February 29th. The requirements for a given year to be a leap year are: The year must be divisible by 4 If the year is a century year (1700, 1800, etc.), the year must be evenly divisible by 400 Some example leap years are 1600, 1712, and 2016. Write a program that takes in a year and determines whether that year is a leap year. Ex: If the input is 1712, the output is: 1712 is a leap year. Ex: If the input is 1913, the output is: 1913 is not a leap year. 1 2 3 4 5 6 7 8 9 10 11 Put("{} is a leap year.".format(i_year)) print("{} is not a leap year.".format(i_year)) inputYear = Get next input What would be the code?Part 2: Binary Arithmetic One of the most common operations we perform on binary numbers (and all numbers) is addition. It can be cumbersome to convert your binary numbers to decimal just to add them and convert them back, so instead we will be learning how to add binary numbers directly. Binary addition works the same way as decimal addition, with the added restriction that each digit can only go up to 1. Let's consider the possibilities for adding the values of any 2 single digits together: 0 + 0 0 + 1 1 + 0 1 + 1 0 1 1 10 (remember that 10 in binary represents the number 2) In that last case, the result is larger than a single digit. When adding larger binary numbers, that means we have to carry the 1 over to the next column. This presents us with another new case: what happens if we have 1 + 1 + carried 1? In that case, the result is 11, which means that column's result is 1, and we carry 1 to the next column. Below is an example of adding two binary numbers that shows all…
- Tiling: The precondition to the problem is that you are given threeintegers n, i, j, where i and j are in the range 1 to 2n. You have a 2n by 2n squareboard of squares. You have a sufficient number of tiles each with the shape . Your goalis to place nonoverlapping tiles on the board to cover each of the 2n × 2n tiles except forthe single square at location i, j. Give a recursive algorithm for this problem in whichyou place one tile yourself and then have four friends help you. What is your base case?Introductory: The Caesar Cipher technique is one of the earliest and simplest methods of encryption techniques. It is simply a type of substitution cipher, i.e., each letter of a given text is replaced by a letter some fixed number of positions down the alphabet. For example, with a shift of 1, A would be replaced by B, B would become C, and so on. The method is apparently named after Julius Caesar, who apparently used it to communicate with his officials. Thus, to cipher a given text we need an integer value, known as a shift which indicates the number of positions each letter of the text has been moved down. The encryption can be represented using modular arithmetic by first transforming the letters into numbers, according to the scheme, A = 0, B = 1 ,…, Z = 25. Encryption of a letter by a shift n can be described mathematically as. En(x) = (x+n) mod 26 (Encryption Phase with shift n) Write an algorithm and implement a program in C to read the data from a file (called…PYTHON: In order to beat AlphaZero, Grandmaster Hikaru is improving her chess calculation skills.Today, Hikaru took a big chessboard with N rows (numbered 1 through N) and N columns (numbered 1 through N). Let's denote the square in row r and column c of the chessboard by (r,c). Hikaru wants to place some rooks on the chessboard in such a way that the following conditions are satisfied:• Each square of the board contains at most one rook.• There are no four rooks forming a rectangle. Formally, there should not be any four valid integers r1, c1, r2, c2 (≠r2,c1≠c2) such that there are rooks on squares (r1,c1), (r1,c2 (r2,c1)and (r2,c2).• The number of rooks is at least 8N.Help Hikaru find a possible distribution of rooks. If there are multiple solutions, you may find any one. It is guaranteed that under the given constraints, a solution always exists.InputThe first line of the input contains a single integer T denoting the number of test cases. The first and only line of each test case…
- Question 9 Electrical resistors are said to be connected "in series" if the same current passes through each and "in parallel" if the same voltage is applied across each. If in series, they are equivalent to a single resistor whose resistance is given by + R₂ R = R₁ + R₂ + R3 + If in parallel, their equivalent resistance is given by 1 1 1 1 1 = + + + + R₁. R R₁ R₁ R₂ Write an M- le that prompts the user for the type of connection (series or parallel) and the number of resistors n and then computes the equivalent resistance.## MP (Machine Problem) Details The bulls and cows game is a code-breaking game designed for two or more players. Each player chooses a secret code of 4 digits from 0 – 9. The digits must be all different. The goal of the game is for each player to guess the other player's secret code. The players in turn present their guesses to the opponents. The opponents respond by telling the players: 1. The number of bulls, i.e. the number of matching digits in their right positions, and 2. The number of cows, i.e. the number of matching digits but in different positions. ### Requirements The main goal of this assignment is to develop the bulls and cows game that allows a single player to play interactively against the computer. The game stores two secret codes, one from the player and one from the computer. The player and the computer will try to guess each other’s secret code. Both the player and the computer only have seven attempts for guessing the secret code. If the player enters invalid…When you borrow money to buy a house, a car, or for some other purpose, you repay the loan by making periodic payments over a certain period of time. Of course, the lending company will charge interest on the loan. Every periodic payment consists of the interest on the loan and the payment toward the principal amount. To be specific, suppose that you borrow $1,000 at an interest rate of 7.2% per year and the payments are monthly. Suppose that your monthly payment is $25. Now, the interest is 7.2% per year and the payments are monthly, so the interest rate per month is 7.2/12 = 0.6%. The first months interest on $1,000 is 1000 0.006 = 6. Because the payment is $25 and the interest for the first month is $6, the payment toward the principal amount is 25 6 = 19. This means after making the first payment, the loan amount is 1,000 19 = 981. For the second payment, the interest is calculated on $981. So the interest for the second month is 981 0.006 = 5.886, that is, approximately $5.89. This implies that the payment toward the principal is 25 5.89 = 19.11 and the remaining balance after the second payment is 981 19.11 = 961.89. This process is repeated until the loan is paid. Write a program that accepts as input the loan amount, the interest rate per year, and the monthly payment. (Enter the interest rate as a percentage. For example, if the interest rate is 7.2% per year, then enter 7.2.) The program then outputs the number of months it would take to repay the loan. (Note that if the monthly payment is less than the first months interest, then after each payment, the loan amount will increase. In this case, the program must warn the borrower that the monthly payment is too low, and with this monthly payment, the loan amount could not be repaid.)