Lab Exercises: 1. Write a script that will generate a random number between 1 and 20 and the user needs to guess that number. If the user enters a wrong number, print a message that indicates that. The user needs to keep trying until the user guesses the right number. Once the user guesses the right number, the program needs to stop and print a message telling the user that he/she guessed the number. 2. Write a function that will take an email from the user as an input, check if the email is in correct format: Email Id (Text before the @ sign) with a length greater than 2. O rion 2.1. 22
Q: 3. Twin Primes A prime number is any integer greater than 1 that is divisible (without remainder) by…
A: Program: def twinPrimes(a,b):t=[]while a<=b:if a==1 or a==2:a+=1continueif isPrime(a):if…
Q: [Question Description] Write a function to find the factorial using the formula n!=1*2*3*...*n, such…
A: There were no restriction stated hence made this way. Screenshot is also attached.
Q: In mathematics, a harshad number is an integer that is evenly divisible by the sum of its digits.…
A: Programming instructions: Use a loop to iterate from 1 to 1000000. In the loop, call the function…
Q: Take in numbers about 4 times and create a function that adds those four numbers together. Use that…
A:
Q: 1. A prime number is a number that is only evenly divisible by itself and 1. For example, the number…
A: C++ Code with isPrime function #include <iostream> using namespace std; bool isPrime(int n)…
Q: In coral language: One lap around a standard high-school running track is exactly 0.25 miles. Write…
A: A required program is as follows, Program: Function MilesToLaps(float userMiles) returns float…
Q: Exercise - Return Values Write a function called greeting that takes a String argument called name,…
A: Given:
Q: change.py Create a program, change.py, that has a function that takes 5 arguments that…
A: According to the information given:- We have to follow the instruction to create a program,…
Q: A bullet train slows from a speed of 200 mi/hr to 150 mi/hr in one minute. Write a computer program…
A: The answer is
Q: The cost to become a member of a fitness center is as follows: (a) the senior citizens discount is…
A: Program: //include the required header files #include <iostream> #include <string>…
Q: A county collects property taxes on the assessment value of property, which is 60 percent of the…
A: The program defines a variable value which accepts the actual value of the property. Another…
Q: In mathematics, a factorial of a number is calculated by multiplying that number by all of the…
A: I have written the code below:
Q: Write a program whose inputs are three integers, and whose outputs are the largest of the three…
A: A Corel is a simple high level programming language. It is also used for making flowchart. We type…
Q: Write code to check if a number 0 or 6 was entered on the command line when a 0 variable was…
A: Programming language is not mentioned so I wrote it in c language:…
Q: Write a function called zero_smaller(int &, int &) that is passed two int arguments by reference and…
A: Since you are not mentioning the programming language, here we are using C++ to complete the…
Q: In C++, a function can be overloaded. Select one: O True O False What will be the output when the…
A: Find the required answer with explanation given as below :
Q: LAB: User-Defined Functions: Miles to track laps One lap around a standard high-school running…
A: Step-1: Start Step-2: Declare a variable miles and take input Step-3: Call function MilesToLaps,…
Q: You must write a function control (p_nr) that calculates and returns the control digit in a 10-digit…
A: Iterate over the given number and find control_sum by adding individual numbers multiplied by their…
Q: In 2022 population of town A is less than population of town B. However, the population of town A…
A: Use a for loop which can iterate for 50 times but we can exit when population of A exceeds…
Q: Create a function that takes the number x and the letter y ("m“ for the male, "f" for the female),…
A: In this problem we need to design a code to display the gernation as per the given information. In…
Q: 5: Complete the function that takes in a number x, and returns the value 1 if x > 0, otherwise it is…
A: Logic:- within step_function use if else to check value of x is greater than or equal to 0 or not.…
Q: 1. Write a script that will generate a random number between 1 and 20 and the user needs to guess…
A: Question number 1 please, in python language. Answer in step2
Q: 9. You are a class teacher at a kindergarten school. As a task, you asked your students to write a…
A: 1) Below is program to read a string from user and capitalize the string and display It defines a…
Q: The cost to become a member of a fitness center is as follows: (a) the senior citizens discount is…
A: Program code: //include the required header files #include <iostream> #include <string>…
Q: Write a function max_magnitude() with two integer input parameters that returns the largest…
A: Algorithm of function max_magnitude(user_val1, user_val2): 1. Check condition: 1.1. IF absolute…
Q: c++ Write a function that will generate a random number between 1 and 100. Then it ask the user to…
A: #include <iostream>#include<cstdlib>#include<ctime>using namespace std; int…
Q: Write the function to print whether number can be divided by 3 on the screen. Print "Can be…
A: Below is the required code in C language. Program Approach: Including necessary header files for…
Q: HOMEWORK 6 PART 1 Date Due: Wednesday, April 14, 2021 at 11:59pm Complete a program that allows the…
A: A function is a sub-program that is called from the main function to execute. Read the choice from…
Q: y = floor( x + 0.5 ); rounds the number x to the nearest integer and assigns the result to y. use…
A: C++ code for above : #include <iostream>#include <math.h>using namespace std; int…
Q: T-Shirt: Write a function called make_shirt( that accepts a size and the text of a message that…
A: (1) Program code: def make_shirt(size, message): ''' print the summary of the shirt that is…
Q: 5.8 LAB: Flip a coin efine a function named CoinFlip that returns "Heads" or "Tails" according to a…
A: Total answers posted by the expert is: 77519 import java.util.Scanner;import java.util.Random;public…
Q: In mathematics, a factorial of a number is calculated by multiplying that number by all of the…
A: The programming language is missing in the question, the below answer is provided in C language. If…
Q: Task 1 Write a function called even_checker that takes a number as an argument and prints whether…
A: Code: n=int(input("Please Enter a number: "))#taking user inputdef even_checker(n):#function to…
Q: The use ofcomputers in education is referred to as computer-assisted instruction (CAI). Write a…
A: #include <iostream>using namespace std;int ResultChecking(int a, int b){ while(true)…
Q: Write a function that prints characters using the following header:def printChars(ch1, ch2,…
A: NOTE: SINCE THE LANGUAGE OF THE PROGRAM IS NOT MENTIONED, I HAVE USED JAVA FOR THE SOLUTION. Define…
Q: 1. The function get Thousands () should return the thousands digit of the number; e.g., 1=get…
A: The function for the about given program is given below:
Q: Čonsider the following program: def calculate (value): return value + value def main (): result =…
A: Given: Goal: We have to write a python program in which we define two functions, main and…
Q: (PYTHON) (Display characters) Write a function that prints characters using the following header:…
A: Coded using Python 3.
Q: Exercise 1: Write a Python program that inputs five positive integer numbers, finds their maximum…
A: The ask is to write a Python program which does the following: - Takes five positive numbers as…
Q: Program 3: Write a value-returning function isVowel that returns the value true if a given character…
A: Aim: Write a value returning function isVowel to find if a character is a vowel or not. The program…
Q: 9. You are a class teacher at a kindergarten school. As a task, you asked your students to write a…
A: The program is written in Python. Please check step 2 for source code
Q: Complete the check_strings_same_start(word1, word2) function which is passed two string parameters.…
A: def check_string_same_start(word1, word2): if(len(word1)%2==0 or len(word2)%2==0):…
Q: 4. (Prime Numbers) An integer is said to be prime if it is divisible by only 1 and itself. For…
A: Below is the required C++ program: - Approach: - Importing the header file and the namespace.…
Q: “Days Into Year (C++)” By using my code (photo is attached), implement a Days Into Year function.…
A: A date has to be taken from user in the required format. A function that returns how many days we…
Q: leff 0:55:32 Write a program that request from the user enters the integer number with six digits.…
A: #include <stdio.h> int main(void) { int n; printf("Enter a Six digit number: "); scanf("%d",…
Q: write a void function divisor that receives an integer number and display its divisor on screen…
A: Note: We are authorized to answer one question at a time, since you have not mentioned which…
Q: Implement a function named get_player_selection. This function has parameters for the players number…
A: Coded using Python 3.
Q: digits.py Create a program, digits.py, that has a function that takes a number and prints the…
A: The problem is based on the basics of functions in python programming language.
Q: Exercise - Seconds since midnight 1 Let's write a program that reads the time from the user as three…
A: 12 o' clock here is assumed to be the midnight 12 o' clock (12:00 am). 1 minute contains 60 seconds.…
Qustion number 3
using paython, please!
Step by step
Solved in 2 steps with 3 images
- c++ Write a function that will generate a random number between 1 and 100. Then it ask the user to guess a number between 1 and 100. If the user’s entry is equal to the random number, it will display “You are a winner”; otherwise, it will display: “You did not win”Write a function named midvalue that is passed three unique int values and returns the one that is in the middle. Thus, midvalue(5,28,14) returns 14.Write a function named midvalue that is passed three unique int values and returns the one that is in the middle. Thus, midvalue(5,28,14) returns 14. C++
- Implement a function named get_player_selection. This function has parameters for the players number (which will be either 1 or 2), and the number of sticks remaining on the board. For this function you will need to do the following: Use the input function to get the player to type in their selection. Validate the user’s input, printing out a message if they enter an invalid number and continually prompting them until they do enter a valid number. The user may enter any number between 1 and 3, unless there are fewer than 3 sticks remaining, in which case they can only enter between 1 and the number of sticks remaining. As in the example, the input prompt should list the valid range of numbers. Return the (validated) number as an integer (not a string). You should test that this function works by running it in the REPL. Make sure you try different scenarios, like the user entering an invalid number multiple times in a row. After you are done testing and fixing any errors you find,…change.py Create a program, change.py, that has a function that takes 5 arguments thatcorrespond to the number of $1 dollar bills, quarters, dimes, nickels, andpennies, respectively. Calculate the total value of that change, and print "Thetotal value of your change is $x" where x is equal to the total value.T-Shirt: Write a function called make_shirt( that accepts a size and the text of amessage that should be printed on the shirt. The function should print a sentencesummarizing the size of the shirt and the message printed on it. Then- Call the function once using positional arguments to make a shirt. Call thefunction a second time using keyword arguments.Large Shirts: Modify the make_shirt() function so that shirts are large by default witha message that reads | love Python. Then- Make a large shirt and a medium shirt with the default message, and a shirt ofany size with a different message.
- Given person_is_old(age) which returns True or False based on the incoming age as an integer. Write a function that uses the one mentioned above so that it prints “Go to work!” if the person is not old and “You deserved to have a long vacation” otherwise. Your function must also accept the age as its argument. My code def funct2(age): flag = old_person(age) if(flag): print("You deserved to have a long vacation") else: print("Go to work!")(Perfect Numbers) An integer number is said to be a perfect number if its factors, including1 (but not the number itself), sum to the number. For example, 6 is a perfect number because 6 =1 + 2 + 3. Write a function isPerfect that determines whether parameter number is a perfect number. Use this function in a program that determines and prints all the perfect numbers between 1and 1000. Print the factors of each perfect number to confirm that the number is indeed perfect.Challenge the power of your computer by testing numbers much larger than 1000.Python task You must write a function control (p_nr) that calculates and returns the control digit in a 10-digit social security number if you send in the first 9 digits in the form of a string. The rules for calculating the check digit in a social security number are as follows:The numbers are multiplied alternately by 2 and 1 and then the products are summed. For a two-digit product, the sum of its numbers is calculated. The sum is then subtracted from the nearest higher tens to obtain the check digit.To calculate the check digit for the social security number with the first 9 digits 811218987, perform the following setup: 8 1 1 2 1 8 9 8 7 2 1 2 1 2 1 2 1 2 16 1 2 2 2 8 18 8 141 + 6 + 1 + 2 + 2 + 2 + 8 + 1 + 8 + 8 + 1 + 4 = 44The check digit is 50-44 = 6 # test personal_number = input () control_digit = control(personal_number) print(control_digit)
- (Time in Seconds) Write a function that takes the time as three integer arguments (forhours, minutes, and seconds) and returns the number of seconds since the last time the clock “struck12.” Use this function to calculate the amount of time in seconds between two times, both of whichare within one 12-hour cycle of the clock“Days Into Year (C++)” By using my code (photo is attached), implement a Days Into Year function. It MUST BE of this form: int daysIntoYear ( int year, int month, int day ) ; In terms of "Days Into Year," how many days are we into the year based on a given date? For example, January 1 is 1 day into the year. Please have the code display 12 test cases with the result from the function, and the number of days into the year from some other source. So you can hand calculate the days into the year or use an internet web page. The typical output might look like this: (Please make the format better but be sure to automatically calculate agree/disagree column) You must include a leap year function that returns a bool and takes as a parameter the year. This function must be used in your code. Year Month day Days Into Year Value expected Agree/Disagree 2020 1 1 1 1 agree 2020 1…A bank charges $10 per month, plus the following check fees for a commercial checking account: $0.10 each for less than 20 checks $0.08 each for 20 through 39 checks $0.06 each for 40 through 59 checks $0.04 each for 60 or more checks Write a function BankCharges() that allows the user to enter the number of checks written and computes and displays the bank’s service fees for the month. All checks for the month are assigned the same charge, based on the total number of checks written during the month. Use the following test data to determine whether the application is calculating properly. In each case, the customer is charged only a single rate, based on the total number of checks. Your solution should clearly show the function. Customer Number of Checks Bank Charges Nancy 15 Lilian 25 Arianna 45 Ben 75