Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Need help with python coding, Program 2, 3 and bonus Program 2: (Vector Math) [35 points] This program is meant to give you practice with

Need help with python coding, Program 2, 3 and bonus

Program 2: (Vector Math) [35 points]

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 3: (Password Protection) [30 points]

This program is mean tot 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 of the program, you are to read in a single integer that states the number of username/password pairs that you will read in. Following this, there will be a set of that many user names, one per line. Then there will be a set of that 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

G$a-4(ztY

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. If they have an incorrect username/password, 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.

Activity # BONUS: Chessboard moves (BONUS PROBLEM) [30 points]

The purpose of this activity is to get you used to using lists of lists, in a 2-D matrix-like format.

Write a program that sets up a chess board with chess pieces, and lets people make moves (of one piece at a time) on the chess board. Here are the details:

  • The chessboard is an 8x8 board.
  • Display the chess board before every move. Each empty square should just be a period. Each square with a piece should have the pieces identifier.
  • For identifiers, use lower-case for the white pieces, upper-case for the black pieces.
    • Use P/p for pawn, R/r for rook, N/n for knight, B/b for bishop, Q/q for queen, and K/k for king.
  • When a piece is moved, the location it moves from is then an empty square, and it then occupies the square it is moving to. If there was already a piece in the square it is moving to, then that other piece is eliminated from the game.
  • Important: You do NOT need to enforce any rules of chess or verify moves, with one exception:
    • If someone puts in a move from a position where there is not a piece, report an error and exit the program.
    • Other than that, you dont need to worry about the sides alternating turns, about pieces moving in ways they arent allowed, about landing on your own pieces, etc.
    • Only one piece moves at a time, and it can move to any position on the board.
  • You can specify the system you want the user to use to specify the starting and ending location.
    • In reality, chess uses a standard system, where the columns are labeled a-h from left to right and the rows are labeled 1-8 from bottom to top. You do not have to use this system, but can if you wish.

As an example, here is what the board would look like at the very beginning of the game:

RNBQKBNR

PPPPPPPP

........

........

........

........

pppppppp

rnbqkbnr

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

Recommended Textbook for

Introductory Relational Database Design For Business With Microsoft Access

Authors: Jonathan Eckstein, Bonnie R. Schultz

1st Edition

1119329418, 978-1119329411

More Books

Students also viewed these Databases questions