Question

In: Computer Science

I'm making a python program that checks the users input. If the users input does not...

I'm making a python program that checks the users input. If the users input does not match the rules then the program will output "No". If the users input does match the rules it will output "Yes".

The rules are :

5 uppercase letters

5 lowercase letters

5 numbers

First letter must be capitilized

The total characters must be 15

I have managed to meet these conditions in individual python files but not in one. Ideally without importing anything, still learning the basics as you can see! Thanks

Solutions

Expert Solution

PYTHON CODE:

# variable to store the uppercase count
upper_case=0

# variable to store the lowercase count
lower_case=0

# variable to store the number count
numbers = 0

# flag to store first letter capital or not
firstletter=False

# getting the user input
word=input('Enter a string: ')

# getting the length of the word
length =len(word)

# looping through every character in the word
for c in word:

    # if the character is upper,increment the upper_case by 1
    if c.isupper():
        upper_case+=1

    # if the character is lower,increment the lower_case by 1
    if c.islower():
        lower_case+=1

    # if the character is digit,increment the numbers by 1
    if c.isdigit():
        numbers+=1

# checking the first character uppercase or not
if word[0].isupper():
    firstletter=True


# checking the gives rules
if length == 15 and firstletter and upper_case==5 and lower_case ==5 and numbers ==5:

    # if all the rules are satisfied, print "Yes"
    print('Yes')
else:

    # otherwise, print "No"
    print("No")


SCREENSHOT FOR CODING:

SCREENSHOT FOR OUTPUT:


Related Solutions

I'm making a python program that checks the users input. If the users input does not...
I'm making a python program that checks the users input. If the users input does not match the rules then the program will output "No". If the users input does match the rules it will output "Yes". The rules are : at least 5 uppercase letters at least 5 lowercase letters at least 5 numbers No more than 20 characters in total I have managed to meet these conditions in individual python files but not in one. Ideally without importing...
PYTHON Write a program that accepts a range of input from the user and checks whether...
PYTHON Write a program that accepts a range of input from the user and checks whether the input data is sorted or not. If the data series is already sorted your program should print “True” or should print “False” otherwise. You should not use any sort function for this program. Input: How many numbers you want to input: 3 # user input 3 Input the number: 5 Input the number: 2 Input the number: 7 Output: False
Making a program in Python with the following code types. I'm very confused and would love...
Making a program in Python with the following code types. I'm very confused and would love the actual code that creates this prompt and a brief explanation. Thanks! A comment on the top line of your program containing your name. A comment on the second line containing your section number. A comment on the third line containing the date. A comment on the fourth line containing your email address. A comment with the lab number and purpose of this lab....
PYTHON Write a python program that encrypts and decrypts the user input. Note – Your input...
PYTHON Write a python program that encrypts and decrypts the user input. Note – Your input should be only lowercase characters with no spaces. Your program should have a secret distance given by the user that will be used for encryption/decryption. Each character of the user’s input should be offset by the distance value given by the user For Encryption Process: Take the string and reverse the string. Encrypt the reverse string with each character replaced with distance value (x)...
I'm working on a to-do list program in Python 2. I'm trying to delete an item...
I'm working on a to-do list program in Python 2. I'm trying to delete an item from the list and I'm not sure what I'm missing to do that. I haven't been able to get it to delete by string or by index number. Also, I'm trying to get the menu to run again after the user completes the add/delete/etc options. Do I need to put menu() menu_option = int(input("Welcome to your To-Do List. Please choose and option to continue:...
Create a program that ask to input two users and the result will vary on their...
Create a program that ask to input two users and the result will vary on their name with similar digits. In a game of F.L.A.M.E.S , it will count and repeat depends on their name that has a similar digit. For an Example (JOE RIZAL) and (JACKLYN BRACKEN) - JOE RIZAL has - 5 similar digits , while JACKLYN BRACKEN has 6 similar digits so a total of 11. F - Friends - 1,7 L - Lover - 2,8 A...
PYTHON In this lab we will design a menu-based program. The program will allow users to...
PYTHON In this lab we will design a menu-based program. The program will allow users to decide if they want to convert a binary number to base 10 (decimal) or convert a decimal number to base 2 (binary). It should have four functions menu(), reverse(), base2(), and base10(). Each will be outlined in detail below. A rubric will be included at the bottom of this document. Menu() The goal of menu() is to be the function that orchestrates the flow...
Write a program in python that corrects misspelled words. The input for the program is either...
Write a program in python that corrects misspelled words. The input for the program is either a string or a list of strings. The output should be a string or a list depending on the input and should have the spellings corrected. The speller should be able to correct at least the words listed below. You are free to use any data structures we have covered so far including lists and dictionaries. Your program should be in autocorrect.py. Here is...
Python Coding 1. validate_username_password(username, password, users): This function checks if a given username and password matches...
Python Coding 1. validate_username_password(username, password, users): This function checks if a given username and password matches in the stored users dictionary. This function returns True if a match found otherwise returns False. 2. validate_existing_user(users): This function asks for username and password and checks if user provided name and password matches. It prints an informational message and returns username if it does find a match. Call validate_username_password() function to perform this validation. A user has total of three chances to validate....
I'm working on python code which is substring matching. For example, the given string is input...
I'm working on python code which is substring matching. For example, the given string is input "CTTGTGATCTCGTGTCGTGGGTAG", and a substring we want to find in the main one is "GTGG". So the code will print out the position and the substrings in the main which has exactly one different position. For example, start at position 4 the substring is GTGA since there is only one letter different, and so on. Even though we know that string index starts at 0,...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT