Provide your own examples of the following using Python lists. Create your own examples. Do not copy them from another source. Nested lists The “*” operator List slices The “+=” operator A list filter A list operation that is legal but does the "wrong" thing, not what the programmer expects Provide the Python code and output for your program and all your examples.

Answers

Answer 1

Lists are used in Python to hold multiple values in one variable

(a) Nested list

A nested list is simply a list of list; i.e. a list that contains another list.

It is also called a 2 dimensional list.

An example is:

nested_list = [[ 1, 2, 3, 4]  , [ 5, 6, 7]]

(b) The “*” operator

The "*" operator is used to calculate the product of numerical values.

An example is:

num1 = num2 * num3

List slices

This is used to get some parts of a list; it is done using the ":" sign

Take for instance, you want to get the elements from the 3rd to the 5th index of a list

An example is:

firstList = [1, 2 ,3, 4, 5, 6, 7]

secondList = firstList[2:5]

The “+=” operator

This is used to add and assign values to variables

An example is:

num1 = 5

num2 = 3

num2 += num1

A list filter

This is used to return some elements of a list based on certain condition called filter.

An example that prints the even elements of a list is:

firstList = [1, 2 ,3, 4, 5, 6, 7]

print(list(filter(lambda x: x % 2 == 0, firstList)))

A valid but wrong list operation

The following operation is to return a single list, but instead it returns as many lists as possible

def oneList(x, myList=[]):

   myList.append(x)

   print(myList)

oneList(3)

oneList(4)

Read more about Python lists at:

https://brainly.com/question/16397886


Related Questions

At what layer in the TCP/IP protocol hierarchy could a firewall be placed to filter incoming traffic by means of:

a) message content
b) source address
c) type of application​​

Answers

The answer is c) type of application

The most significant protocol at layer 3, often known as the network layer, is the Internet Protocol, or IP.The IP protocol, the industry standard for packet routing among interconnected networks, is the source of the Internet's name.  Thus, option C is correct.

What are the TCP/IP protocol hierarchy could a firewall?

Application-layer firewalls operate at the TCP/IP stack's application level (all browser traffic, or all telnet or ftp traffic, for example), and thus have the ability to intercept any packets going to or from an application. They stop different packets (usually dropping them without acknowledgment to the sender).

Firewalls are frequently positioned at a network's edge. An external interface is the one that is located outside the network, while an internal interface is the one that is located inside the firewall.

Therefore, The terms “unprotected” and “protected,” respectively, are sometimes used to describe these two interfaces.

Learn more about TCP/IP here:

https://brainly.com/question/27742993

#SPJ2

Which type of research source lets a technical writer observe how a product works?

Answers

Answer:

Research to Support Your Technical Communication

As a buyer for a clothing retailer, for example, you might need to conduct research to help you determine whether a new line of products would be successful in your store. As a civil engineer, you might need to perform research to determine whether to replace your company's current surveying equipment with 3D-equipped stations. And as a pharmacist, you might need to research whether a prescribed medication might have a harmful interaction with another medication a patient is already taking

Explanation:

Hope it helps

Please mark as brainliest

Write a program that reads the student information from a tab separated values (tsv) file. The program then creates a text file that records the course grades of the students. Each row of the tsv file contains the Last Name, First Name, Midterm1 score, Midterm2 score, and the Final score of a student. A sample of the student information is provided in StudentInfo.tsv. Assume the number of students is at least 1 and at most 20.
The program performs the following tasks:
Read the file name of the tsv file from the user.
Open the tsv file and read the student information.
Compute the average exam score of each student.
Assign a letter grade to each student based on the average exam score in the following scale:
A: 90= B: 80=< X < 90
C: 70=< X < 80
D: 60=< X < 70
E: X < 60
Compute the average of each exam.
• Output the last names, first names, exam scores, and letter grades of the students into a text file named report.txt.
• Output one student per row and separate the values with a tab character.
• Output the average of each exam, with two digits after the decimal point at the end of report.txt. Hint: Use the setprecision manipulator to format the output.
Ex: If the input of the program is:
StudentInfo.tsv
and the contents of Studentinfo tsv are:
Barrett Edan 70 45 59
Bradshaw Reagan 96 97 88
Charlton Caius 73 94 80
Mayo Tyrese 88 61 36
Stern Brenda 90 86 45
the file report.txt should contain:
Barrett Edan 70 45 59 F
Bradshaw Reagan 96 97 88 A
Charlton Caius 73 94 80 B
Mayo Tyrese 88 61 36 D
Stern Brenda 90 86 45 C
Averages: midtermi 83.40, midterm2 76.60, final 61.60

Answers

#include
#include
#include
#include
#include
#include


using namespace std;

// Class student required to store the data
class Student{
public:
string lname;
string fname;
int marks[3];
char grade;

// Function which generates the grade for student
void calculate_grade(){
double sum = 0;
for(int i=0;i<3;i++){
sum+= marks[i];
}
double average = sum/3;
if(average>=90 && average<100)
this->grade = 'A';
else if(average>=80)
this->grade = 'B';
else if(average>=70)
this->grade = 'C';
else if(average>=60)
this->grade= 'D';
else this->grade = 'F';
}
};

// This function reads the file , and creates a vector of Students data
vector read_file(string fileName){

// Opening the file
fstream fin;
fin.open(fileName);


// Temp variables
vector list;
vector row ;
string line, word, temp;

// Read the data into vector
while(getline(fin,line)){
row.clear();
stringstream s(line);

while(getline(s,word,'\t')){

row.push_back(word);

}
Student st;
st.fname = row[0];
st.lname = row[1];
st.marks[0] = stoi(row[2]);
st.marks[1] = stoi(row[3]);
st.marks[2] = stoi(row[4]);
st.calculate_grade();
list.push_back(st);
}
fin.close();
return list;
}

// This function takes filname to be output as input, and list of student
void writeFile(string filename, vector list){

// Opening the new file
ofstream fin(filename);
for(int i=0;i string line = list[i].fname+"\t"+list[i].lname+"\t"+to_string(list[i].marks[0])+"\t"
+to_string(list[i].marks[1])+"\t"+to_string(list[i].marks[2])+"\t"+list[i].grade+"\n";
fin<
}


// Find the stats required
double average1 =0,average2 =0 ,average3 = 0;
for(int i=0;i average1+=list[i].marks[0];
average2+=list[i].marks[1];
average3+=list[i].marks[2];
}
average1/=list.size();
average2/=list.size();
average3/=list.size();

// Writting the stats
fin<<"\n"<<"Average: "<<"mid_term1 "<
// Closing the file
fin.close();
}
int main(){

// Taking the input
cout<<"Enter the filename: ";
string filename;
cin>>filename;
vector list;

// Reading and Writting to the file
list = read_file(filename);
writeFile("report.txt",list);


}

People can use computers for sending ....... writing reports, listening to music and playing games. ​

Answers

Answer:

the answer is messages, emails, texts

Hope This Helps!!!

Answer:

People can use computers for sending   MESSAGES'TEXT'EMAILS   ,writing reports,listening to music and playing games....

match the following. dont answer if you dont know please.

Answers

Answer:

instructions= command

the background screen on a computer= desktop

an organized system= folder

list of commands= GUI

performing more then 1 task= multi tasking

an object that contains multiple files= dictionary

graphical user inference= menu

Explanation:

hope this help :)

As a Waterfall project manager, your goal is to minimize any changes that could lead to scope creep. You want to protect your team from building something the client or stakeholders don’t want. What formal and rigorous process could you set up to safeguard against this?

Answers

The necessary things that should be done to avoid a project scope creep include documenting the project requirements and setting up change control processes.

The scope of a project simply means the work that is required in order to complete a project. On the other hand, project scope creep means the occurrence that happens when changes are made to the scope without a change request.

To avoid project scope creep, it's important to document the project requirements, set up changes in control processes, and have a clear project schedule.

Learn more about projects on:

https://brainly.com/question/4853153

write the definition of a void function that finds the integer value of an ascii character

Answers

The code below is in Java.

It converts the given character to corresponding integer value by creating a function. We use type casting to get the integer value of a character.

I also included the main part so that you can test it.

You can see the output in the attachment.

Comments are used to explain each line of code.

public class Main

{

public static void main(String[] args) {

 //call the function in the main

 convertASCIIToInt('k');

}

//create a function named convertASCIIToInt that takes a character as an argument

public static void convertASCIIToInt(char c) {

    //convert the argument to an int using type casting

    int asciiValue = (int) c;

   

    //print the result

    System.out.println("The integer value of " + c + " is " + asciiValue);

}

}

You may see another function example in the following link

https://brainly.com/question/13925344

Question # 9
Multiple Choice
Which option best describes open source software?


a type of software that can be freely used and modified

a type of software that works well with almost all applications and drivers


a type of software used to sync up to Windows


a type of software used to bundle products together

Answers

Answer:

the first option is the best description for an OSS

- Are you interested in modern technology? Why/why not?​

Answers

Answer:

yes

Explanation:

cause it is very intrested

LIKE sitting in the house and turning on your car and alexa all the stuff

Suppose a password must have at least 8, but no more than 12 characters, where each character can be either:

Answers

Answer:

A combination of uppercase letters, lower case letters, numbers, and special characters.

Explanation:

A password is a word that permit you to register, log or sign in a site.

how many MB are there in 1000 KB?

Answers

Answer:

1 megabyte

Explanation:

Ok so there should be 1

Complete the statement using the correct term.
The [blank] of the site is what will be displayed on the web page.

answer is Body

Answers

The BODY of the site is what will be displayed on the web page. It contains most of the distinctive content of the web page.

A web page refers to a document exhibited by the browser, which is generally written in the HTML language.

The body of a web page is a big area in the center that contains the most important and distinctive content of a web page.

The body will determine the central content of the HTML document, which will be observable on the web page (e.g., a photo gallery).

Learn more about a web page here:

https://brainly.com/question/16515023

Which of the following is NOT an example of editing?
O Adjusting photos
O Cutting video and audio
O Proofreading written content
O Designing graphics

Answers

Answer:

ang answer po at proofreading written

content

Explanation:

if I wrong please correction me!

Where is the option to set Conditional Formatting rules found?
O Insert tab in the Formatting group
O Page Layout tab in the Styles group
O Home tab in the Styles group
Formulas tab in the Formatting group

Answers

Answer:

C. Home tab in the Styles group

Explanation:

answer on edge 2021

Question 4 A data analyst wants to include a line of code directly in their .rmd file in order to explain their process more clearly. What is this code called

Answers

A line of code that can be inserted directly into a .rmd file is called an inline code.

R Markdown (.rmd file) is a file format that is typically used for making dynamic documents by using R Studio and R programming language. Also, R Markdown files can be used in the following ways:

To save, organize, and document an executable code.To create a record of any cleaning process.To generate reports containing an executable code for stakeholders.

In R Studio, an inline code is a line of code that can be inserted directly into a R Markdown (.rmd file), in order to explain a process more clearly.

Read more on R Markdown here: https://brainly.com/question/25558534

A new printer has recently been installed in the office, but it does not print. What is the first source to check for information about the problem? *

The manufacturer's website
Tech support forums
The OS website
POST card

Answers

Hi hi hi hi hi hi hi hi hi

I have a D in one of my majors, I got a lot of 70s and I'm failing music. im in middle school. Will I be held back? Please answer this

Answers

Answer:

probably sorry it will be okay

Depends on where you’re from and what grading scale is used. I wouldn’t say you’re ruined if you push hard the rest of the year.

why do you think mobile devices have CPUs that are less powerful than those in a larger desktop computer?

Answers

Mobile CPUs are found in laptops and are often slower than their desktop counterparts because they have to be more power-efficient and generate less heat. High power consumption and high heat generation can be a problem for a battery-powered laptop with a relatively small chassis

Mobile devices have CPUs that are less powerful than those in a larger desktop computer needs power as well as the device memory that was needed is not present.

What is CPU?

The central processing unit also known as CPU is an important part of the computer as it posses the part where the basic functions like taking actions, input or ouput etc. This all process needs high power and battery as well as storage.

For a battery excessive electricity utilization and significant temperature rise can just be problems. The CPU of a device cannot be powered at higher, continuous levels using such a little battery.

As a result, the most recent cellphone cannot compete with the performance of a top-tier desktop computer. the processor as well as the battery is needed for a CPU that can not be in mobiles.

Learn more about CPUs, here:

https://brainly.com/question/16254036

#SPJ2

The ratio of sparrows to bluejays at the bird sanctuary was 5 to 3 If there were 15 bluejays in the sanctuary, how many sparrows were there?​

Answers

The answer is 25 sparrows.

A sample member of the list data is a1 = ['male', True] where the second item is True if the person is on the phone.

for item in data:
if item[0] == 'male':
males = males + 1
if item[___
]:
malesOnPhone = malesOnPhone + 1
Choices are 1, 2, 3. Answer is for if item[___]:

Answers

Answer:

0

Explanation:
In the lists, indexation starts from 0, because of that in if statement we compare item[0] which is 'male' and 'male', and then males is itterated within for loop.

Three steps can be taken to construct a list of elements using a for loop: Make an empty list appear. Iterate through an iterable or set of elements. Add each component to the list's end.

What loop for sample member of the list data?

An Array List can be looped through using an Iterator. If there are additional members in the Array List, the method hasNext() returns true; otherwise, it returns false. If there is no next element, the method next() raises the No Such Element Exception and returns the next element in the Array List.

FOR LOOPS and WHILE LOOPS are two popular types of loops. A For loop runs a variable number of times. LOOP TYPE — FOR LOOP When you know how many times you want to run an algorithm before stopping, you use for loops.

Therefore, Since indexation in lists begins at 0, we must compare item[0], which is “male,” with “male” in the if statement before iterating through males in the for loop.

Learn more about loop here:

https://brainly.com/question/14390367

#SPJ2

Please debbug this code for me

public class SavingAccount { // interest rate for all accounts private static double annualInterestRate = 0; private final double savingsBalance; // balance for currrent account // constructor, creates a new account with the specified balance public void SavingAccount( double savingsBalance ) { savingsBalance = savingsBalance; } // end constructor // get monthly interest public void calculateMonthlyInterest() { savingsBalance += savingsBalance * ( annualInterestRate / 12.0 ); } // end method calculateMonthlyInterest // modify interest rate public static void modifyInterestRate( double newRate ) { annualInterestRate = ( newRate >= 0 && newRate <= 1.0 ) ? newRate : 0.04; } // end method modifyInterestRate // get string representation of SavingAccount public String toString() { return String.format( "$%.2f", savingsBalance ); } // end method toSavingAccountString } // end class SavingAccount

Answers

Answer:

/

Explanation:

You have just purchased a brand new Windows 8 computer. What should you do right away with the Administrator account?

Answers

The correct answer is:

Enable EFS for the account

The collection of ____ bits make one nibble​

Answers

Answer:

Hewo There!!

__________________

4

__________________

“It's really a wonder that I haven't dropped all my ideals, because they seem so absurd and impossible to carry out. Yet I keep them, because in spite of everything, I still believe that people are really good at heart.”

― Anne Frank, The Diary of a Young Girl

__________________

Think of life as a mytery because well it sort of is! You don't know what may happen may be good or bad but be a little curious and get ready for whatever comes your way!! ~Ashlynn

explain the use of mail merge feature.
pls help​

Answers

Mail Merge is a handy feature that incorporates data from both Microsoft Word and Microsoft Excel and allows you to create multiple documents at once, such as letters, saving you the time and effort of retyping the same letter over and over.

describe the process of terminating a crossover cable​

Answers

Background: In the Information Technology World, the Ethernet cable has been the most trusted medium that is link computers to the world wide web. However, in recent years, wireless technology has limited the use of the Ethernet cable. Nonetheless, true computer geeks know that in order to receive optimum speed within a computer network in a business or inside our homes; the proper cabling technics are crucial when installing a computer network. Therefore, this instructable will provide step-by-step procedures on the proper way to terminate a CAT 6 cable using the TIA 568B standard for a straight-through cable. The procedures used for the straight-through cable can also be utilized to terminate a cross-over and roll-over cable.

Cable Pin-outs: Straight-Through, Cross-over, and Roll-over cables

Step 1: Prepare the cable

Using the cable snips, remove approximately one half inch of outer cable sheath/jacketing from each cable end.

Step 2: Cut cable wires to the appropriate length

Cutting the wires to the proper length allows for the CAT 6 cable to properly fit in the RJ-45 connector.

Step 3: Align cable wires for the specific configuration that will be terminated

The alignment of the wires will ensure they enter the proper channel within the RJ-45 connector when inserting the wires.

Step 4. Slide cable into the RJ-45 Connector

When sliding the cable into the RJ-45 connector, use enough force to ensure the end of the wires are seated firmly at the end of the RJ-45 connector channels.

Step 5. Insert the RJ-45 connector in the crimping tool and Crimp the RJ-45 connector

When inserting the cable into the crimping tool, use enough force to ensure that the cable doesn’t slide out of the crimping tool and the wires do not become misaligned. In addition, while crimping the connector, use enough force to push the copper conductors down on to the wires and the plastic tab on to the outer sheath of the cable. You will hear a click once all the copper tabs are seated properly.

Step 6. Perform a visual inspection of the connector

The visual inspection is to ensure that the connector is properly terminated to the cable. Look for issues with wire alignment and connector looseness.

Step 7. Repeat steps to terminate multiple connectors.

difference between syntax error and semantics
error

Answers

Answer:

The syntax error is an incorrect construction of the source code, whereas a semantic error is erroneous logic that produces the wrong result when executed.

Explanation:

Syntax

It refers to the rules of any statement in the programming language.

Semantics

It refers to the meaning associated with any statement in the programming language

Write a python program to calculate the sum of three numbers and as well require the user to input the numbers.​

Answers

Answer:

numbers = []

for i in range(3):

 numbers.append(eval(input("Enter number: ")))

print('Sum is:', sum(numbers))

Explanation:

You want to use a loop to prevent repeating your code.

Answer:

numbers = []

for i in range(3):

numbers.append(eval(input("Enter number: ")))

print('Sum is:', sum(numbers))

An input statement is used to interact with the user of a program.
True False

Answers

Answer:

True.

Explanation:

An input statement asks a user a question, where the user has to input a value for the program to move forward. This means that yes, the program does interact with the user.

what is operating system?​

Answers

The software that supports a computer's basic functions, such as scheduling tasks, executing applications, and controlling peripherals.

Journalize the following transactions using the direct write-off method of accounting for uncollectible receivables.

April. 1 Sold merchandise on account to Jim Dobbs, $7,200. The cost of goods sold is $5,400.
June 10 Received payment for one-third of the receivable from Jim Dobbs and wrote off the remainder.
Oct. 11 Reinstated the account of Jim Dobbs and received cash in full payment.

Answers

The journal entry for the transactions will be:

1st April

Debit Account receivables $7200

Credit Sales $7200

(To record sales)

Debit Cost of goods sold $5400

Credit Inventory $5400

(To record cost of goods sold)

10th June

Debit Cash $2400

Credit Account receivable $2400

(To record cash received from customer)

Debit Allowance for uncollectible items $4800

Credit Account receivable $4800

(To record write-off)

11th October

Debit Account receivable $4800

Credit Allowance for uncollectible items $4800

( To record reinstatement of account)

Debit Cash $4800

Credit Account receivable $4800

( To record full cash gotten from customer)

The account receivable on 10th June was calculated as:

= (1/3 × $7200) = $2400

Learn more about journal entry on:

https://brainly.com/question/8913038

Other Questions
please please help i beg ill give brainlist how long should you wait to eat after brushing your teeth Under the Articles of Confederation, justice and law enforcement are left to __________. A. the nation B. the states C. the people D. Congress solve for Xexplain steps too pls d. What do you like to do in the rain? How old would u be if you was born in 1475 and died in 1946 Define quadrilateral triangle ? Give two examples what is -25pi over 12 in degrees Question 21 of 35Which layer in this model represents the coolest part of the geosphere?BD, . 0 , ODD in the book the giver who is the person that designates assignments 14m - 7Please help asap Consider the substances quartz (SiOs), gold (Au), and nitrogen gas (N2). If possible, use the termsmolecule and compound to describe each substance. If one or more of the substances cannot bedescribed by the terms molecule and compound, explain why not. Look at the table displaying data collected in a health class after a test is taken.Scores Based on Average Time StudyingTime spent studying (hours)Score on test (%)0450.25480.5560.75621701.5802832.5763903.2596498What would most likely help improve the lowest test scores?practice analyzing diagramseffective time managementuse of mnemonic deviceshelp reading scientific content solve by elimination Help answer these chemistry questions Using the timeline above about what year did the Aztec civilization begin? A) 1200 BCE B) 1200 CE C) 1428 CE D) 1521CE Working together, Shawn and Hector can install a tile floor in 6 hours. It would take Shawn 9 hours to do the job alone. What is the value of r, Hectora's rate of work in part per hour? Compare the location and size of the prepuce in the fetal pig and in the human How much money should be invested every quarter at 9% per year, compounded quarterly, in order to have $3000 in 8 years? (Round your answer to the nearest cent.) Question 6 of 10How do you say "Jacinta called three hours ago" in Spanish?O A. Jacinta llama en tres horas.O B. Jacinta llamaba por tres horas.O C. Hace tres horas que Jacinta llam.O D. Hace tres horas que Jacinta llama.