Question

In: Computer Science

plz answers these short Qs in python language Q1-Given three int variables that have been given...

plz answers these short Qs in python language

Q1-Given three int variables that have been given values, areaCode, exchange, and lastFour, write a string expression whose value is the string equivalent of each these variables joined by a single hyphen (-) So if areaCode, exchange, and lastFour, had the values 800, 555, and 1212, the expression's value would be "800-555-1212". Alternatively, if areaCode, exchange, and lastFour, had the values 212, 867 and 5309 the expression's value would be "212-867-5309"

Q2-Write statement that defines plist to be a list of the following ten elements: 10, 20, 30, ..., 100 in that order.

Q3-Associate True with the variable has_dups if the list list1 has any duplicate elements (that is if any element appears more than once), and False otherwise

Q4-Given that plist has been defined to be a list of 30 elements, add 5 to its last element. You can assume that the last element is a number.

.

Solutions

Expert Solution

Python version : 2.7

1.

# str function converts int to string

# + concatenates the string

areaString = str(areaCode)+"-"+str(exchange)+"-"+str(lastFour)

print(areaString)              

2.

# creates a list plist containing ten elements 10,20,30,...,100 in that order

plist = [10,20,30,40,50,60,70,80,90,100]

3.

has_dups = False # set has_dups = False

# loop over list list1

for i in range(len(list1)):

               # if count of any elements in list1 is greater than 1 then set has_dups to True

               if(list1.count(list1[i]) > 1):

                              has_dups = True

4.

# plist[-1] refers to the last element of plist

# the below statement adds 5 to the last element of plist
plist[-1] = plist[-1] + 5


Related Solutions

Given the following int variables which represent a date, int day; // 0-6 for Sunday-Saturday int...
Given the following int variables which represent a date, int day; // 0-6 for Sunday-Saturday int month; // 1-12 for January-December int date; // 1-31 int year; // like 2020 Define the function void tomorrow(int& day, int& month, int& date, int& year); which updates the variables to represent the next day. Test in main().
Q1: Given the following code, what is returned by tq(4)? int tq(int num){ if (num ==...
Q1: Given the following code, what is returned by tq(4)? int tq(int num){ if (num == 0) return 0; else if (num > 100) return -1; else     return num + tq( num – 1 ); } Group of answer choices: 0 4 -1 10 Q2: Given that values is of type LLNode<Integer> and references a linked list (non-empty) of Integer objects, what does the following code do if invoked as mystery(values)? int mystery(LLNode<Integer> list) {    if (list.getLink() ==...
This is C++ programming Given an int variable k, an int array incompletes that has been...
This is C++ programming Given an int variable k, an int array incompletes that has been declared and initialized, an int variable nIncompletes that contains the number of elements in the array, an int variable studentID that has been initialized, and an int variable numberOfIncompletes, Write code that counts the number of times the value of studentID appears in incompletes and assigns this value to numberOfIncompletes. You may use only k, incompletes, nIncompletes, studentID, and numberOfIncompletes. I tried this code...
plz short answers Q 1 In your opinion, how analyzing cost behaviour is useful? Discuss why...
plz short answers Q 1 In your opinion, how analyzing cost behaviour is useful? Discuss why contribution margin and break-even can be used by managers? Answer the two questions using graphs in your analysis.
     i What values would be stored in the given variables in each case? a.          int n =...
     i What values would be stored in the given variables in each case? a.          int n = 12 % 5; b.          double x = 15 % 11 + 5.3 - 5 / (2.5 - 0.3); c.   float y = 2 / (3.5 + static_cast<int>(3.5)); d.   bool z = (6 – 7 <= 2 * 1) && (5 + 4 >= 3) || (6 + 2 != 17 – 3 * 10);
Q1: A sample with two variables (x and y) is given in the table. According to...
Q1: A sample with two variables (x and y) is given in the table. According to the sample, please develop an excel spreadsheet to calculate the missing values given in the table of “summary output” attached below. The excel spreadsheet needs to be submitted together with your assignment. Note: use “data analysis toolpak” to check your answers, but calculations, equations and steps should be done for each "?" value x y 1.0 5.2 1.5 7.2 2.0 5.5 2.5 4.9 3.0...
Java program to implement circular linked list. NO COPY PASTE ANSWERS plz follow the given template......
Java program to implement circular linked list. NO COPY PASTE ANSWERS plz follow the given template... public class CircularLinkedList { private Node tail; private int size; public CircularLinkedList() { tail= null; size = 0; } public int size(){ return size; } public boolean isEmpty() { return size==0; } //if list is not empty return the first element public E first() { if (isEmpty()) return null; //code here return 0; } //if list not empty return last element public E last()...
i want good answer with example plz i have a project useing java language but theacher...
i want good answer with example plz i have a project useing java language but theacher tell us u must use (java.util.Date) only to get the current year and month how can i do that plz jst using that class no celender or somthing else i need current year and current month to calculate the gurantee year and the guranttee month thax☺️
Python # Write a program that examines three variables—x, y, and z # and prints the...
Python # Write a program that examines three variables—x, y, and z # and prints the largest odd number among them. # If none of them are odd, it should print a message to that effect. n = input('Enter the 1st Integer x: ') x = int(n) n = input('Enter the 2nd Integer y: ') y = int(n) n = input('Enter the 3rd Integer z: ') z = int(n) if x % 2 == 0 and y % 2 ==...
1. We have the data as follows. There are three independent variables and three dependent variables...
1. We have the data as follows. There are three independent variables and three dependent variables (You may use the following table to solve this problem) x y 3 11 5 6 7 4 Total 15 21 a) Calculate b1 and b0, and write the equation of the least squares line. b) Determine the values of SSE and SST. c) Calculate the standard error. d) Find the rejection point for the t statistic at α = .05 and test H0:...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT