Question

In: Computer Science

USE PYTHON : # Problem Set 04: - Write a function to seek for all even...

USE PYTHON :

# Problem Set 04:
- Write a function to seek for all even numbers and odd numbers in the middle of two number A and B. Print even and odd numbers in 1 and 2020 (including both these two numbers)

# Problem Set 05:
- A website requests an user to input his account password.
- Write a program to examize the validity of the password.
- The valid password must consists of:
- At least 1 letter in [a-z]
- At least 1 number in [0-9]
- At least a letter in [A-Z] (capital)
- At least one special letter in [$#@]
- At least 6 letters in total
- At most 12 letters in total
- The program can accept a list of passwords that are split by commas.
- Print all valid passwords in a line and split by commas
- Examples:
- Input: ABd1234@1,a F1#,2w3E*,2We3345
- Output: ABd1234@1

Solutions

Expert Solution

In case of any queries, please revert back.

==================== CODE BELOW FOR QUESTION 4 WITH COMMENTS ======================

def get_even_odd(A,B):
    #We use lists for this
    odd_nums = []
    even_nums = []
    # Go over A and B, and store even and odd into respective lists
    for i in range(A,B+1):
        if i%2==0:
            even_nums.append(i)
        else :
            odd_nums.append(i)
    print("Even Numbers are :- ",end=" ")
    for i in even_nums:
        print(i,end=" ")
    print()
    print("Odd Numbers are :- ", end=" ")
    for i in odd_nums:
        print(i, end=" ")

get_even_odd(1, 20)

============== CODE BELOW FOR QUESTION 5 ======================

def check_val(string):
    # Make some checks for number,capital Letter,normal Letter,special Character
    numCheck = False
    capitalLetter= False
    smallLetter = False
    specialLetter = False
    # Now, check each letter in password and check validity
    for letter in string:
        if letter.islower() == True:
            capitalLetter=True
        elif letter.isupper() == True:
            smallLetter = True
        elif letter.isdigit() == True:
            numCheck = True
        else:
            specialLetter = True
    # If all these checks are passed, we check length and return True
    if numCheck==True and capitalLetter==True and smallLetter==True and specialLetter==True:
        if len(string)>=6 and len(string)<=12:
            return True
        return False
    return False

def get_corr_pswd(string):
    # Split the list
    list_pswds = string.split(",")
    for pswd in list_pswds:
        # For each password, check validity and print
        if check_val(pswd)==True:
            print(pswd)

get_corr_pswd("ABd1234@1,a F1#,2w3E*,2We3345")

================ SCREENSHOTS BELOW ========================


Related Solutions

Use Python for this quetions: Write a python functions that use Dictionary to: 1) function name...
Use Python for this quetions: Write a python functions that use Dictionary to: 1) function name it addToDictionary(s,r) that take a string and add it to a dictionary if the string exist increment its frequenc 2) function named freq(s,r) that take a string and a record if the string not exist in the dictinary it return 0 if it exist it should return its frequancy.
Use the following two loop strategies to write a function that sums all even numbers before...
Use the following two loop strategies to write a function that sums all even numbers before an odd number is observed in any given numeric vector, and test your code in R. For example, if the input vector is 2, 4, -2, 3, 4, 5, then the first odd number appears in the fourth position, which is 3. The output should be the sum of the first to the third numbers, which will be 2 + 4 − 2 =...
Python Problem 3 Write a function named enterNewPassword. This function takes no parameters. It prompts the...
Python Problem 3 Write a function named enterNewPassword. This function takes no parameters. It prompts the user to enter a password until the entered password has 8-15 characters, including at least one digit. Tell the user whenever a password fails one or both of these tests.
In python please write the following code the problem. Write a function called play_round that simulates...
In python please write the following code the problem. Write a function called play_round that simulates two people drawing cards and comparing their values. High card wins. In the case of a tie, draw more cards. Repeat until someone wins the round. The function has two parameters: the name of player 1 and the name of player 2. It returns a string with format '<winning player name> wins!'. For instance, if the winning player is named Rocket, return 'Rocket wins!'.
Write a Python program that calls a function to sum all the numbers in a list...
Write a Python program that calls a function to sum all the numbers in a list and returns the result to the caller. The main program creates a list (with hard-coded or user input) and passes the list as an argument to the function. You may not use the built-in function, sum. The program calls a second function to multiply all the numbers in a list passed to it by main and returns the product back to the caller. List...
17. Write a function in Python which removes a set of common words from a long...
17. Write a function in Python which removes a set of common words from a long piece of text. Be sure to strip out any punctuation. The common words to be removed are: ​​a, an, as, at, by, for, in, is, it, of, that, this, to, was, will, the These are typical words which are considered to have low semantic value. Process each paragraph provided below individually. Your end result for each paragraph should be a string or list containing...
Python Write a for loop with a range function and format output as currency Use an...
Python Write a for loop with a range function and format output as currency Use an input statement to ask the user for # of iterations using the prompt: #? [space after the ?] & assign to a variable Convert the variable to an integer Use a for loop and a range function to display all whole numbers from 1 to the user entered number Display the value of the item variable on screen in each iteration in the following...
Use Python: # Problem Set 01: - Develop neurons and print truth table of the following...
Use Python: # Problem Set 01: - Develop neurons and print truth table of the following 2-input logic gates: AND, OR, NAND, NOR, XOR, XNOR and 1-input NOT gate (Notice: use Markdown to explain how you developed a neuron, and to insert images showing the truth table of logic gates before coding) # Problem Set 02: - Develop neuron and print truth table of XOR gate using only NAND gates - Develop neuron and print truth table of XOR gate...
Use Python ## Problem Set 3 - James is looking for his dream job, but has...
Use Python ## Problem Set 3 - James is looking for his dream job, but has some restrictions. He loves California and would take a job there if it paid over 40,000 a year. He hates Massachusetts and demands at least 100,000 to work there. Any other place he’s content to work for 60,000 a year, unless he can work in space in which case he would work for free. - Write a program to capture the above statement -...
Use Python Write a function that takes a mobile phone number as a string and returns...
Use Python Write a function that takes a mobile phone number as a string and returns a Boolean value to indicate if it is a valid number or not according to the following rules of a provider: * all numbers must be 9 or 10 digits in length; * all numbers must contain at least 4 different digits; * the sum of all the digits must be equal to the last two digits of the number. For example '045502226' is...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT