Question: 1 . Implement two lists. One list should be a list of 8 different usernames with one being admin. The other list should be a

1. Implement two lists. One list should be a list of 8 different usernames with one being "admin".
The other list should be a list of 8 different messages (pleasant messages like: "Hope you are well today! etc.)
Be sure to use for loops and/or the appropriate control structure.
Check to see if the user equals 'admin'.
If so print an f-string, passing {user} directly to the print stream with a message stating: "I have a status report for you!".
If using nested for loops for example, break out of the inner loop appropriately. If the user isn't admin, then generate a random choice from the messages list and
print and f-string, passing each user directly to the print stream along with the random message.
If using nested for loops, break out of the inner loop after printing each random greeting.
Hint: You will break out of the inner loop twice (if you nest). You don't have to though. Iterate over the names list, and then handle your message logic in the same loop.
You need to try your best to derive a solution that you understand. There is no right or wrong here.
BE SURE TO IMPORT THE RANDOM MODULE
Hint: your_variable_handle = random.choice(messages)
'''
#YOUR CODE GOES HERE
'''
2. Amend the above program and prompt the user to log in with their username.
a. If the user is in the list (think conditionals here) continue with the above implementation (#1 above).
b. If name entered is not in the list, print: Sorry, username does not exist
'''
#YOUR CODE GOES HERE
'''
3. Simulating Username Uniqueness Check on a Website
a. Create a list consisting of 8 usernames, making sure to mix upper and lowercase letters, such as "kfoster2342" or "Ddouglas1345345."
b. Now, create a second list containing 8 new usernames. Ensure that at least 3 of the usernames in this second list match those from the first list, but vary the casing.
c. Write a loop that checks each of the new usernames against the existing ones. If the username is found in the current list, display a message telling the user to pick another username. If its not found, print a message indicating that the username is available for use.
d. Be mindful of case sensitivity when comparing usernames. For instance, if "Kfoster2342" is already on the list but the new user attempts to use "kfoster2342," the system should recognize this as a duplicate. To handle this, create a new list where all usernames from the original list are converted to lowercase.
For example:
current_users =[list of current usernames]
new_users =[list of new usernames]
lower_case_users =[user.lower() for user in current_users]
In the code above, the square brackets are used to generate a new list using list comprehension. List comprehension is a concise and efficient way to create a list by transforming another list or string. In this case, we are converting each username from current_users into lowercase. Each item in current_users is processed one by one (iterated over), and during each iteration, the username is converted to lowercase and stored in the new lower_case_users list.
'''
#YOUR CODE GOES HERE
'''
4. Implement a list with 4-6 items. Unpack it using each way outlined in the lecture materal being sure to print each time (use list comprehension, the .join function and others).
'''

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!