Answer:
part 1:
Explanation:
Write a recursive function named double_digits that accepts an integer as a parameter and returns the integer obtained by replacing every digit with two of that digit. For example, double_digits(348) should return 334488. The call double_digits(0) should return 0. Calling your function on a negative number should return the negation of calling it on the corresponding positive number; for example, double_digits(-789) should return -778899.
Answer:
A recursive function known as double-digit is a function that accepts as a parameter and returns the integer that is obtained by changing each digit with double digits. For example 425 should be return as 442255.
In the given scenario
the function will be as follow
If
def double_digits:
n < 0:
return -1 * double_digits ( -1 * n )
elif n = 0
return o
else:
result
double_digits ( n // 10 )
return int ( str ( result ) + str ( n % 10 ) + str ( n % 10 )
Test the function as follow
print ( double_digits ( 348 ) )
Result
334488
Test the function as follow
print ( double_digits ( 0 ) )
Result
0
Test the function as follow
print ( double_digits ( -789 ) )
Result
-778899
Write a method called isMagicSquare that accepts a two-dimensional array of integers as a parameter and returns true if it is a magic square. A square matrix is a magic square if it is square in shape (same number of rows as columns, and every row the same length), and all of its row, column, and diagonal sums are equal. For example, [[2, 7, 6], [9, 5, 1], [4, 3, 8]] is a magic square because all eight of the sums are exactly 15.
Answer:
def isMagicSquare(myArray: list) -> bool :
row_num = len(myArray)
cols_num = [len(x) for x in myArray]
count =0
for x in cols_num:
if row_num == x:
count += 1
if count == len(cols_num):
return True
else:
return False
print(isMagicSquare([[1,2,3,1],[3,34,2,4],[43,5,7,5],[2,3,4,5]]))
Explanation:
In object-oriented programming, a method is a function defined in a class. Methods are actions that can be taken or executed in a class or to a class object.
The "isMagicSquare" is a python function or method in a class that returns true if a two array or list is a perfect square (same column and row length).
Explain to Alana why she might not want to blast her boss on social media just yet.
Answer: She might get fired. And who knows, if she doesn't, she might get a raise!
Describe the general strategy behind deadlock prevention, and give an example of a practical deadlock prevention method.
Multi-programming (or multi-tasking) enables more than a single process to apparently execute simultaneously. How this can be achieved on a uni-processor?]
Answer:
In multi-programming, you use semaphore constructs to protect shared resources. Your program thread or process will block if you want to claim a semaphore when another thread or process has it claimed.
Generally you need to keep the code scope of the claimed semaphore (a.k.a. the critical section) as small as possible, and also, prevent claiming another semaphore within a given critical section.
How many times will line 7 be executed when the following code is run?
String str = "rebellion";
int i = 0;
int j = str.length() - 1;
String result = "";
while (i < j)
{
result = str.substring(i, i + 1) + result + str.substring(j, j + 1);
i++;
j--;
}
System.out.println(result);
(Java)
Answer:
4 times
Explanation:
Required.
How many times will line 7 be executed?
Line 2 initialises i to 0
Line 3 subtracts 1 from the length of "rebellion" , the result of the subtraction is then saved in J
So:
j = 9 - 1
j = 8
From line 2 and line 3, we have that:
i = 0 and j = 8
Line 4 is an iteration that is repeated as long as i is less than j
Line 7 will be executed, for the first time as: i < j because 0 < 8
i is incremented to 1 and j is reduced to 7
Line 7 is then executed again, the second time because 1 < 7
i is incremented to 2 and j is reduced to 6
Line 7 is then executed again the third time because 2 < 6
i is incremented to 3 and j is reduced to 5
Line 7 is then executed again the fourth time because 3 < 5
i is incremented to 4 and j is reduced to 4
At this stage, line 7 will no longer be executed because I is no longer less than as 4 = 4.
Hence, number of execution is 4 times
Add the beginning comments at the top of the program.
In the first part of your program, create a for loop that runs three times:
Inside the for loop, prompt the user for an integer
Prompt the user for another integer
Call the function compare (you are going to create this function next)
Pass the variables that you used for the integer inputs from above
Create a function called compare (remember the function definition should go at the top of the program) and use two variables in the parameters of the function:
Inside of the function, create an if / elif / else structure that compares the two values passed into the function
If one value is less than the other, output that to the user (Ex: 2 is less than 4)
Elif the other value is less than the other output something similar (Ex: 4 is less than 9)
Else, output that they are equal to each other
That is it for the first part of the program.
Next, create an empty list called names.
Create a loop that runs 6 times:
Inside of the for loop, prompt the user for a name
Append the name to the list
Outside of the for loop, prompt the user for how many people they would like to vote off the island.
Call the function eliminate and pass the variable you used from step 7 to it.
Also, this function will return a value, so store this back function call back to a new variable.
Create a function called eliminate and create a variable to use as the parameter:
Inside the function, randomly shuffle (use the shuffle() method) all the values in the list (you will need to import random at the top of the program)
Then using a for loop, loop it as many times as the value that was passed to the function:
Inside the for loop, remove one name from the list (use the pop() method)
Outside the for loop, but still inside the function, return the list of remaining people
Underneath where you left off in step 8, print the remaining people that are left: those that did not get voted off the island.
WILL GIVE BRAINIEST!
Answer:
#################
# Python Practice
#################
# Part 1
# ------------------------------------------------------
run_compare = 3
ran_compare = 0
while run_compare != ran_compare:
num1 = int(input('Please input the first number: '))
num2 = int(input('Please input the second number: '))
def compare(number1, number2):
if number1 < number2:
print(f'{num1} is less than {num2}')
elif number1 > number2:
print(f'{num1} is greater to {num2}')
else:
print(f'{num1} is equal than {num2}')
compare(num1, num2)
ran_compare += 1
# ------------------------------------------------------
# Part 2
run_name = 6
ran_name = 0
names = []
# ------------------------------------------------------
while run_name != ran_name:
name = input(str('Please insert a name: '))
names.append(name)
print(names)
ran_name += 1
# ------------------------------------------------------
give me a second im going to resolve the last part but this is what i have so far
Following are the program to the given question:
Program Explanation:
Import random package as r.Defining a method "compare" that takes two variable "n1,n2" inside the parameter.In the next step, a conditional statement is declaed that checks the parameter value and prints its value. Defining a method "eliminate" that takes two variable "n, names" inside the parameter.It calls the shuffle method, and define a for loop that removes names value and return its value.In the next step, a for loop is defined inside this two variable "i1, i2" is declared that inputs value and calls the comapre value.In the next line, an empty list "names" is declared inside this a for loop is defined that inputs name value and calls the "eliminate" method and print its calculated value.Program:
import random as r#import package random
def compare(n1, n2):#defining a method compare that takes two parameters
if n1<n2:#defining if block that checks n1 value less than n2 value
print("{} is less than {}".format(n1, n2))#print value with the message
elif n2<n1:#defining if block that checks n2 value less than n1 value
print("{} is less than {}".format(n2, n1))#print value with the message
else:#defining else block
print("{} and {} are equal".format(n1, n2))#print value with the message
def eliminate(n, names):#defining a method eliminate that takes two parameters
r.shuffle(names)#calling the shuffle method
for i in range(n):#defining a for loop that checks n values
names.pop()#calling pop method to remove value
return names #return a names value
for i in range(3):#defining a for loop that inputs value
i1 = int(input("Enter an integer: "))#defining i1 value to input value
i2 = int(input("Enter another integer: "))#defining i2 value to input value
compare(i1, i2)#calling the compare method
print()#using print to break line
names= [] #defining an empty list
for i in range(6) :#defining a loop that inputs name value
name = input("Enter name: ")#defining name variable that inputs value
names.append(name)#calling append method
n = int(input("\nHow many people you would like to vote off the island: "))#defining n variable that input value
new_names = eliminate(n, names)#defining new_names that calling eliminate method
print("\nRemaining people that did not get voted off the island:")#print message
if(len(new_names) != 0):#defining if block that checks new_names length not equal to 0
for name in new_names:#defining a for loop that checks name is in new_names
print(name)#print name value
else:#defining else block
print("None")#print message None
Output:
Please find the attached file.
Learn more:
brainly.com/question/21922031
Why do people want phones so bad??
To help explain this, take a look at these reasons why kids should have cell phones:
#1 To keep in touch. What happens if you're running late picking your child up from school? ...
#2 To talk to friends. ...
#3 To stay safe. ...
#4 To develop essential skills. ...
#8 To improve their organization. ...
#11 To encourage responsibility.
Which of the following apertures will give you the shallowest depth of field?
a)2.8
b)5.6
c)11
d)22
e)2
50 points and brainliest
Answer:
a.2.8
The f-stops work as inverse values, such that a small f/number (say f/2.8) corresponds to a larger or wider aperture size, which results in a shallow depth of field; conversely a large f/number (say f/16) results in a smaller or narrower aperture size and therefore a deeper depth of field.
Biodiversity explanation
hurry i need help swear to god i will give brainliest not lying
Answer:
finding area of a circle
def area(radius):
int(radius)
formula = radius * radius * 3.14
print(formula)
radius_input = int(input('Insert the radius of your circle: '))
area(radius_input)
hope this helped :D
dad always arrives home from work thoroughly exhausted
As you draw a star, pressing the shift key while you drag increases the number of points on the star. True or false
Answer:
true
Explanation:
The OpenMP critical-section compiler directive is generally considered easier to use than standard mutex locks, because
Complete question
A) management of entry and exit code is managed by OpenMP library reducing the possibility of programming errors.
B) programmers don't need to worry about race conditions.
C) a thread cannot block inside a critical section.
D) deadlock cannot occur.
Answer:
A. Management of entry and exit code is managed by OpenMP library reducing the possibility of programming errors
Explanation:
This is a multiple choice question and this is the answer because:
1. OpenMp is inclusive of an APL/compiler directives:
2. any code which follows #pragma omp parallel is a parallel region and it is performed by large number of threads that are same as the number of processing cores that are in the system.
3. The critical-section compiler directive acts more like a binary semaphore or mutex lock,it makes sure that only one thread is active in the critical section at the same time.
fast guys can u tell its answer
find the count of value from cells a5 through e12
Answer:
See the bottom status bar of excel, it will show the average, count and sum of values in the selection.
Write a program that reads a list of integers into a list as long as the integers are greater than zero, then outputs the smallest and largest integers in the list.
Ex: If the input is:
10
5
3
21
2
-6
the output is:
2 and 21
n = 1
lst = []
while n > 0:
lst.append(n := int(input()))
lst.pop(-1)
print(str(min(lst)) +" and "+str(max(lst)))
I wrote this code in python 3.8. I hope this helps
What is a router?
1. a special computer designed to accomplish tasks
2. a device that sends data to the receiving device
3. a set of data sent across networks
4. an Internet site available only to members of a group
Answer:
3
Explanation:
Answer:
it would be 3
Explanation:
because origanally a router is a dwvice that forwards data packets between computer networks.
True or false?
as the speed of a vehicle increases the amount of tire tread touching the road also increase.
What is the thickness of a character’s outline called
Answer:
actually is answer is font weight
hope it helped!
How much data can a flash drive store?
Answer:
depends on which flash drive
Explanation:
32GB-1000 photos
Well, It just depends on which size you get. You could get a 512 MB or 10 GB. I prefer somewhere in the middle because I don't need to store a lot of stuff in my Flash drive.
Factor 72y+108z
lmk the answer asap
Which line of code will move the raft to the Skykomish River?
class raft:
def __init__(self,capacity):
self.capacity = capacity
self.location = 'Gauley'
self.repairs = []
def moveRaft(self, newLocation):
self.location = newLocation
myRaft = raft(30)
A. myRaft.moveRaft(self,'Skykomish')
B. myRaft.moveRaft('Skykomish')
C. moveRaft('self, Skykomish')
D. myRaft.moveRaft() = 'Skykomish'
Answer:
myRaft.moveRaft('Skykomish')
Explanation:
myRaft = raft(30)
myRaft.moveRaft('Skykomish')
If you add the following line, you can see that the raft is now located on the Skykomish River.
myRaft.moveRaft('Skykomish') is the line of code will move the raft to the Skykomish River. Hence, option B is correct.
What is Skykomish River?Given that the North and South Forks of the Skykomish Rivers pass through it, the Upper Sky Valley is a canoeist and angler's dream. The Sky Valley's world-class whitewater rapids are a great option if you're searching for a wilder ride than floating around or wading into many fishing holes.
The Skykomish River will be navigable from its mouth to the point where its north and south forks meet. There will be no impediments in the Snoqualmie River from its mouth to Snoqualmie Falls. As long as the fishery is open, which is anticipated to last until anglers are allowed to keep up to two coho salmon that are at least 12 inches in length.
Thus, option B is correct.
For more information about Skykomish River, click here:
https://brainly.com/question/29104642
#SPJ2
Having too much b-roll footage is often a problem for editors
True
False
verdade pois tem muita filmagem e é dificil escolher a melhor imagem
I am having trouble with doing this code on Python:Develop the Car class by creating an attribute purchase_price (type int) and the method print_info() that outputs the car's information.Ex: If the input is:2011 18000 2018where 2011 is the car's model year, 18000 is the purchase price, and 2018 is the current year, then print_info() outputs:Car's information: Model year: 2011 Purchase price: 18000 Current value: 5770Note: print_info() should use three spaces for indentation.
Answer:
class Car:
def __init__(self, model_year, purchase_price):
self.model_year = model_year
self.purchase_price = purchase_price
self.current_year = 0
self.current_value = 0
def set_current_year(self, year):
self.current_year = year
def calc_current_value(self, current_year):
if self.current_year == 0:
return "Must first input the current year"
depreciation_rate = 0.15
car_age = current_year - self.model_year
self.current_value = round(self.purchase_price - (car_age * (self.purchase_price * 0.15)))
def print_info(self):
print("Car's information:")
print(f"Model year: {self.model_year}")
print(f"Purchase price: {self.purchase_price}")
if self.current_value > 0:
print(f"Current value: {self.current_value}")
else:
print("Current value: Unknown")
Explanation:
The python program above defines the class "Car" that accepts the model year and purchase price of an instance. The class has a set method for the current year variable that is used to calculate and update the current value variable of the object. The print_info method prints the car model year, purchase price and its current value after nth years.
Denise is using Outlook 2016 in a business environment. Her company operates a Microsoft Exchange email server.
When Denise uses the address book, which tool is she using by default?
Offline Address Book
Personal Address Book
Global Address List
Custom Address List
Answer:
Custom Address link
Explanation:
Answer:
D custom address list
Explanation:
Edge 202
If you are working on doing senior portraits and want a lens that will give you the best shallow depth of field which lens would you choose?
a) 55mm f1.2 (focal length of 55mm, maximum aperture of 1.2)
b) 28-80mm f4.5 (Zoom lens with focal length from 28-80mm, max aperture 4.5)
c) 18mm f5.6
d) 50mm f1.4
45 points and brainliest
Answer: The answer is C Hope this helps :) Please mark Brainliest
Explanation:
Answer:
c) 18mm f5.6
Explanation:
For the best lens that offers the best shallow depth of field, you need to choose the one with the maximum apertature but does not zoom.
Hence choice c) has the maximum aperture and does not zoom.
Hope this helps :)
User max owns a directory games, containing a text file called ourgames.txt that he shares with users belonging to the group gameplayers. Those users may read and execute this file, but not delete it. They may not add other files to the directory. Others may neither read, write, nor execute anything in games. What would be the appropriate ownerships and permissions for both directory games and the file ourgames.txt look like
Answer:
The directory games folder: drwxr-x---
ourgames.txt files : -rwxr-x---
Explanation:
The directory games and the ourgames.txt file are owned by max who has read, write and execute permissions for both, where the 'd' in the first column represents the directory. The gameplayers group has read and execute permissions represented by the 'r' and 'x' letters. The other group is the third section with just dashes which means no permission is granted for the file.
When save a newly created template, you use which extension for the file type? .doc, .docx, .doct, .dotx?
Answer:
The main difference between the two file formats is that in DOC, your document is saved in a binary file that includes all the related formatting and other relevant data while a DOCX file is actually a zip file with all the XML files associated with the document.
A company is performing an analysis on the computers at its main office. The computers are spaced along a single row. The analysis is performed in the following way: 1. Choose a contiguous segment of a certain number of computers, starting from the beginning of the row. 2. Analyze the available hard disk space on each of the computers. 3. Determine the minimum available disk space within this segment.
Answer:
array = input("Enter the list of computer memory: ").split(',')
int_arr = [int(x) for x in array]
segment = int(input("Enter the length of segment to analyze: "))
list_len = len(int_arr)
segList = []
mini = []
for x,i in enumerate(int_arr):
seg = int_arr[i-1:segment+i-1]
if len(seg) == segment:
segList.append(seg)
for x in segList:
mini.append(min(x))
result = mini.index(min(mini))
print("Segment with the minimum memory is: ",segList[result])
Explanation:
The python program prints out the segment after analysis, with the smallest disk memory space. The code gets the array of computer rows from the user input and segments the array with the number of segment input, then the minimum is compared for all segments in the network.
Write a program that reads a stream of integers from a file and prints to the screen the range of integers in the file (i.e. [lowest, highest]). You should first prompt the user to provide the file name. You should then read all the integers from the file, keeping track of the lowest and highest values seen in the entire file, and only print out the range of values after the entire file has been read.
Answer:
This question is answered using C++ programming language
#include <fstream>
#include<iostream>
using namespace std;
int main() {
string fname;
cout<<"Enter Filename: ";
cin>>fname;
int lowest = 0;
int highest = 0;
ifstream ifs(fname);
int x;
while (ifs >> x){
if(x < lowest){
lowest= x;
}
if(x > highest) {
highest = x;
}
}
ifs.close();
for(int i = lowest; i<=highest;i++)
{
cout<<i<<" ";
}
}
Explanation:
This line declares fname as string
string fname;
This prompts user for filename
cout<<"Enter Filename: ";
This gets filename
cin>>fname;
This declares and initializes lowest to 0
int lowest = 0;
This declares and initializes highest to 0
int highest = 0;
This defines the file using ifstream
ifstream ifs(fname+".txt");
This declares x as integer. x is used to read integers in the file
int x;
The following iteration will be repeated until there is no other integer to be read from the file
while (ifs >> x){
This checks for lowest
if(x < lowest){
lowest= x;
}
This checks for highest
if(x > highest) {
highest = x;
}
}
This closes the file. i.e. the file has been read
ifs.close();
The following iteration prints the range of values from lowest to highest
for(int i = lowest; i<=highest;i++) {
cout<<i<<" ";
}
Please note that the filename must be entered with its extension
Write a program that declares three one-dimensional arraysnamed miles, gallons, and mpg. Each array should be declared in main() and should becapable of holding ten double-precision numbers. The numbers that should be stored in miles are240.5, 300, 189.6, 310.6, 280.7, 206.9, 199.4, 160.3, 177.4, and 192.3. The numbers should bestored in gallons are 10.3, 15.6, 8.7, 14, 16.3, 15.7, 14.9, 10.7, 8.3, and 8.4.
Answer:
#include <iostream>
using namespace std;
int main(){
double miles[10] = {240.5, 300, 189.6, 310.6, 280.7, 206.9, 199.4, 160.3, 177.4, 192.3};
double gallons[10] = {10.3, 15.6, 8.7, 14, 16.3, 15.7, 14.9, 10.7, 8.3, 8.4};
double mpg[10];
for (int i = 0; i < 10; i++){
mpg[i] = miles[i]/ gallons[i];
cout << "mpg: " << mpg[i] << endl;
}
}
Explanation:
The C++ source code declares three arrays miles, gallons and mpg with an array length of 10. The gallons and miles arrays are assigned 10 array items each and they are used to push values to the mpg array in the for loop statement. The result of each item in the mpg array is displayed on the screen.