Question

In: Computer Science

Write a function called checkFormat that will check the format of a given username to make...

Write a function called checkFormat that will check the format of a given username to make sure it follows some formatting restrictions. This function should take one input parameter – a string that contains the username to be checked. The username should look like [email protected] where cccc can be any 4 lowercase letters. The following conditions must be satisfied to be a valid username:

  1. The length should be 19 characters

  2. The 5th character should be “@”

  3. The username should end with “abcdefghij.edu”

  4. The username should start with 4 lowercase letters

python, use boolean function

Solutions

Expert Solution

def checkFormat(string):
length=len(string)
if(length!=19):
return False
if(string[4]!='@'):
return False
if(string[0:4].islower()==False):
return False
if(string[5:19]!="abcdefghij.edu"):
return False
return True
  
print(checkFormat("[email protected]"))
print(checkFormat("[email protected]"))
print(checkFormat("[email protected]"))
print(checkFormat("abcdtabcdefghij.edu"))
print(checkFormat("[email protected]"))
print(checkFormat("[email protected]"))


Related Solutions

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....
Write a function called format_name that accepts a string in the format of first name followed...
Write a function called format_name that accepts a string in the format of first name followed by last name as a parameter, and then returns a string in reverse order (i.e., last name, first name). You may assume that only a first and last name will be given. For example, format_name("Jared Smith") should return "Smith, Jared" Hint: The following String Methods will be useful: # Returns the lowest index in the string where substring is # found. Returns -1 if...
C# Palindrome Permutation: Given a string, write a function to check if it is a permutation...
C# Palindrome Permutation: Given a string, write a function to check if it is a permutation of a palindrome. A palindrome is a word or phrase that is the same forwards and backwards. A permutation is a rearrangement of letters. The palindrome does not need to be limited to just dictionary words. Input: Tact Coa Output: True (permutations: "taco cat", "atco cta", etc.) Comment your code to explain it.
Write a python program function to check the frequency of the words in text files. Make...
Write a python program function to check the frequency of the words in text files. Make sure to remove any punctuation and convert all words to lower case. If my text file is like this: Hello, This is Python Program? thAt chEcks% THE freQuency of the words! When is printed it should look like this: hello 1 this 1 is 1 python 1 program 1 that 1 checks 1 the 2 frequency 1 of 1 words 1
Part 1: Write a Python function called reduceWhitespace that is given a string line and returns...
Part 1: Write a Python function called reduceWhitespace that is given a string line and returns the line with all extra whitespace characters between the words removed. For example, ‘This line has extra space characters' 'This line has extra space characters’ • Function name: reduceWhitespace • Number of parameters: one string line • Return value: one string line The main file should handle the file operations to read from a .txt file you create and call the function from the...
In C Write a main function with a function call to a function called GetLetter which...
In C Write a main function with a function call to a function called GetLetter which has two double arguments/parameters. The function returns a character. Declare and initialize the necessary data variables and assign values needed to make it executable and to prevent a loss of information
Create a function named getCreds with no parameters that will prompt the user for their username...
Create a function named getCreds with no parameters that will prompt the user for their username and password. This function should return a dictionary called userInfo that looks like the dictionaries below: # Administrator accounts list adminList = [ { "username": "DaBigBoss", "password": "DaBest" }, { "username": "root", "password": "toor" } ] Create a function named checkLogin with two parameters: the userInfo and the adminList. The function should check the credentials to see if they are contained within the admin...
Complete the Python function called 'greetings(time)' that accepts a time in "HH:MM" format as a string....
Complete the Python function called 'greetings(time)' that accepts a time in "HH:MM" format as a string. The function should return a greeting message based on the hour given in the time object as follow: If the time is before noon: 'Good Morning.', if it is in the afternoon: 'Good Day.' Please use the following template for your python script to define the greetings() function and name it as mt_q3.py. Replace the place holder [seneca_id] with your Seneca email user name....
Please write code in Scala Write a function which check that numbers in provided list are...
Please write code in Scala Write a function which check that numbers in provided list are correctly sorted. Please use tail recursion
Write a method called isMatch that takes a string of parentheses and check if all parentheses...
Write a method called isMatch that takes a string of parentheses and check if all parentheses match correctly. The parameter string might consist of other characters. Ignore other characters, just check the () {} [] public static boolean isMatch(String expressionLine); Use a JCF ArrayDeque or LinkedList as a stack to store all open or left parentheses. Use following main method to check your method. public static void main(String[] args) { String[] expression = new String[]{"{5*(x+2)+(y-1);}", "32*(20+(x[i]*3)-1", "((){([][])})", "({}((0))", "{([]})", "{}())",...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT