Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This is a homework assignment that I have due this week but I'm quite behind on the material to complete this assignment. I'm meeting with

This is a homework assignment that I have due this week but I'm quite behind on the material to complete this assignment. I'm meeting with a good friend that has lots of coding experience but I'd like to be more prepared before meeting. Could you do a walk through of this assignment?

image text in transcribedimage text in transcribedimage text in transcribed
ENGR 102 - Lab #5b Problem 1. Removing Duplicates: Write a program that will remove duplicates from a user inputted list. The program should print the original list, the list of duplicates, and a list of unique values. If no, duplicates exist, the program should ONLY print the original list. Problem 2. Armstrong Numbers: You are tasked with writing a program to evaluate if an integer has the property that the sum of the cubes of its digits is equal to the number itself. For example, 371 > 3**3 + 7**3 + 1**3 = 371. Write a program to find all integers that meet this criterion in the range of 0 and 999. Problem 3. Intersection: You are tasked with developing an algorithm to find the intersection of two lists and save it to a new list. If no intersection exists, print 'No intersection exists' otherwise print the intersection. Do not use the any list methods. Use the following lines of code to create two lists of integers for your program: import random num_list1 = random.sample(range(1, 100), 30) Problem 4. List Conditionals: Write a program that asks the user to input a positive integer. The program will continue to run until the user enters -1. If the user enters a positive integer, print "excellent!". If the user enters 0 or a negative integer other than -1, print "Please enter a positive value". If the user does not enter a number, print Please enter positive integer." Each positive integer should be added to a list (List1_all) and each positive integer that is even should be added to a second list (List1_odd). The program should print each list unless there are no elements. Program 5: Vector Math: This program is meant to give you practice with lists and looping on them, as well as practice with vector computations. Write a program that lets a user enter two vectors, A and B, of arbitrary dimension. You should allow the user to first enter the dimension of the vector, then get the elements of the two vectors from the user. Then, you should output (in a clearly labeled way), the results of these computations: The magnitude of vector A and the magnitude of vector B A +B A - B And the dot product (inner product) of A and B Note: You should use lists when solving this problem. Later we will see some other ways to work with vectors more directly. Program 6: Password Protection: This program is mean to give you practice using dictionaries.Write a program that first reads from a user a set of usernames and passwords, and then enters a program that simulates a user typing in passwords. In the first part ofthe program, you are to read in a single integer that states the number of usernamefpassword pairs that you will read in. Following this, there will be a set ofthat many user names, one per line. Then there will be a set ofthat many passwords, one per line. You only need to prompt one time at the beginning of the program. For example, input might be: 3 John Jim Joe SecreT_passWorD 12345 GSa-4(th Once that is read in, you should then repeatedly ask the person to type in a username and then password. If they have a valid username and password combination, then print a message that they are allowed into the system. Ifthey have an incorrect usernamefpassword, then tell them (and allow them} to try again (repeatedly). Note: in practice, although this is the basic way passwords are handled, they should not be stored in unencrypted format even in the program. Instead, passwords are encrypted when they are typed in, they are stored in an encrypted format, and the comparisons are always between encrypted passwords. There are also more extreme security measures. Program 7: List Comprehensions: Using a list comprehension, create a list of tuples that consists of a string and integer where the string is 'even' or 'odd' and the integer ranges from 0 to 20. For example, the first few items in the list would be: [('even',0},('odd',1],l'even',2},...} Program 8: Truth Table: Complete the truth table for the code block shown below. # gnome sort arr = [ 34, 2, 10, -9] n = len{arr) index = 0 while index = arrlindex - 1]: index = index + 1 else: arr[index], arr[index-l] : arr[index-l], arr[index] index = index - l print(\"Sorted sequence after applying Gnome Sort :") for i in arr : print(i, end= ' , ') print (' \ Number of iterations {:d} ' . format (index)) Arr index [34,2,10,-9 n - 34,2,10,-9 4 Name your programs as follows: ENGR102_[sec#]_[fi+last name]_lab6b_[#].py where [sec#] is your section number, [fi+last name] is your first initial added to your last name, and [#] is the problem number. For example, my submission for problem 3 would be named ENGR102_502_ckurwitz_lab6b_3.py

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Programming questions