1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
GREYUIT [131]
3 years ago
5

Write a python program that takes two lists as input from the user, multiplies the index wise elements of the two lists and adds

it to a new variable. While doing the program you should handle the following exceptions: Return an exception if an element in a list is not a number stating “The list has some non number values”. Return an exception if there is an index out of bound stating “Index out of bound”. ============================= Example 1: Input: list_one = [1, a, 2, 4] list_two =[5, 6, 7, 8] Output: The list has some non number values
Computers and Technology
1 answer:
nevsk [136]3 years ago
3 0

Answer:

list_one=[]

list_two=[]

list_three=[]

str1=input("list_one:")

for i in str1:

   if i.isdigit():

       i=int(i)

       list_one.append(i)

   elif i.isalpha():

       list_one.append(i)

str2=input("list_two:")

for i in str2:

   if i.isdigit():

       i=int(i)

       list_two.append(i)

   elif i.isalpha():

       list_two.append(i)

print(list_one)

print(list_two)

if len(list_one)==len(list_two):

   for i in range(len(list_one)):

       multiply=list_one[i]*list_two[i]

       add=str(multiply)

       list_three.append(add)

else:

   print("Index out of bound")

n=0

for i in list_three:

   if i.isdigit():

           n+=1

   else:

       print("The list has some non number values")

print(list_three)

You might be interested in
Why would advertising be more important in a magazine publishing than it is in a newspaper?
Bond [772]
Newspapers are irrelevant now, magazines will get you much more viewers.
3 0
3 years ago
Read 2 more answers
Create a Racket procedure compute_pos that reads numbers from the keyboard until 0 is read, count how many positive numbers are
Artyom0805 [142]

Answer:

import java.util.Scanner;

public class Solution {

   public static void main(String args[]) {

       compute_pos();

     }

     

     public static void compute_pos(){

     Scanner scan = new Scanner(System.in);

     int sum = 0;

     int counter = 0;

     // Prompt the user to enter an input

     System.out.println("Enter your value");

     // user input is assign to the variable value

     int value = scan.nextInt();

     

     while(value != 0){

         if (value > 0){

             sum += value;

             counter++;

         }

         System.out.println("Enter your value");

         value = scan.nextInt();

     }

     // Display the value of sum to the user

     System.out.println("The sum of the positive number is: " + sum);

     // Display the value of counter to the user

     System.out.println("The number of positive number is: " + counter);

   }

}

Explanation:

The first line import the Scanner class which allow the program to read input from the user. The class Solution is then defined. Then the main method which signify the beginning of execution in the program is defined. A method is called inside the main method.

The method compute_pos is defined. Inside the compute_pos method, a scanner object scan is declared to accept input from the user via the keyboard.

The variable sum and counter is declared and assigned to 0.

A prompt is displayed to the user to input a value. The user input is accepted and stored in the variable value.

Then a while loop is use to check the user input if it is not equal to zero. If it is equal to zero, the loop will end. Inside the loop, we first check to see if the user input is greater than 0, if it is, we add it to the variable sum and increase our counter by 1. At the end of the loop, a prompt is again display to accept input from the user.

Outside the loop, we display the sum and counter to the user.

8 0
4 years ago
Which type of website is most likely to be biased when providing information about a product?
vlabodo [156]
If the website is talking about someone or something close to the heart of the website. You wouldn't want the website you work for to talk trash about you.

3 0
4 years ago
Read 2 more answers
En un grupo de estudiantes el 60% son mujeres.Si por todos son 45 ¿cuantos hombres y mujeres son?
enot [183]
27 mujeres
18 hombres

Mira:
60% * 45 = 2,700
2,700/100= 27

Si el 60% son mujeres, entonces
45-27=18 hombres
7 0
3 years ago
A popular game allows for in-app purchases to acquire extra lives in the game. When a player purchases the extra lives, the numb
Taya2010 [7]

Based on the fact that the hacker's actions are done before the application reading of the lives purchased, this is <u>d. Race condition. </u>

<h3>What is a race condition?</h3>

This is when certain processes in an application depend on the timing of a a previous process or event. The flow of information can then be intercepted before the process completes.

This is what the hacker did here by accessing the application to change the number of lives purchased before the application read the number of lives purchased.

In conclusion, option D is correct.

Find out more on the race condition at brainly.com/question/13445523.

4 0
3 years ago
Other questions:
  • Crossing out answers that could not possibly be correct is called ‘eliminating answers.’ Please select the best answer from the
    13·2 answers
  • There are 55 registers, and total 60 instructions available in a general-purpose computer. The computer allows only 2-address in
    6·1 answer
  • If you copy and paste from someone else's document (such as a website, a friend's paper, an instructor's solutions manual, etc.)
    15·1 answer
  • Public classes are accessible by all objects, which means that public classes can be ____, or used as a basis for any other clas
    10·2 answers
  • What is the purpose of saving code snippets?
    7·1 answer
  • Worksheet Identify the devices for moving the cursor around your computer screen
    12·1 answer
  • What is the range for copper tape
    15·1 answer
  • In order to preview an attachment in an e-mail, click the attachment in the ______
    8·1 answer
  • Which command tells the for loop what to count by?
    9·2 answers
  • Which of the following best describes your sequence of actions when developing a web page?
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!