Question

In: Computer Science

Write a python program that asks the user about their emails and then check the following:...

Write a python program that asks the user about their emails and then check the following:

  1. the entered email is a valid email address (email format is [USERNAME]@[ORGANIZATION].[DOMAIN]. i.e. it should have '@' followed by organization name then at least one '.'and domain)
  2. determine if the entered email is a KFUPM email or not (KFUPM emails ends with @kfupm.edu.sa)
  3. if the entered email is a valid KFUPM email, determine if it is a freshman student email or not (assume all freshman students have ID numbers starts with s2019 and the student ID length is 9 digits)
Sample run Sample run Sample run
write your email address: [email protected]
The email address is Valid
The entered email is a KFUPM email
The entered email is a freshman student email
write your email address: ics@104.
The entered email is not valid
write your email address: [email protected]
The email address is Valid

Solutions

Expert Solution

Python program :

#asking user to enter email
email=input("write your email address:")
#checking if email contains @
if(email.find("@")!=-1 and email.find(".")!=-1):
    #if email is valid
    #checking if email contains some domain name
    emailList=email.split(".") #split email based on .
    if(len(emailList)>1 and emailList[1]!=''):#when length of emailList is greater than 2
        #means email contains domain name
        print("The email address is Valid")
        #checking for KFUPM
        if(emailList[0].split("@")[1].upper()=="KFUPM"):
            #when email is KFUPM email
            print("The entered email is a KFUPM email")
            #checking for whether freshman email
            userName=emailList[0].split("@")[0]
            if userName.startswith('s')==True:
                #when email id starts with s then checking for length of email
                #spliting into characters
                idList=list(emailList[0].split("@")[0])
                #declaring variable for digitCount
                digitCount=0
                #using for loop
                for i in range(1,len(idList)):
                    if(idList[i].isdigit()):
                        #when idList is digit then
                        digitCount=digitCount+1 #increment digit count
                if digitCount==9: #when digitCoutn is 9 then
                    print("The entered email is a freshman student email")
        else:#when email does not contains KFUPM
            print("The entered email is a valid email")
    else:#when email contains . but not contains domain name
        print(email + " is not valid")
else: #if email does not contains  @
    print(email+" is not valid")

******************************************************

Screen for indentation :

===================================================

Screen when email is freshman email :

Screen when email is not valid :

Screen when email is KFUPM email :


Related Solutions

Python: Write a program that asks the user for the name of a file. The program...
Python: Write a program that asks the user for the name of a file. The program should display the contents of the file line by line.
Write a program IN JAVA that asks the user for a number. The program should check...
Write a program IN JAVA that asks the user for a number. The program should check the number to ensure that it is valid (if not, the user should enter a valid number to continue.) The program should print out all of the prime numbers from 2 up to the number, with up to 10 numbers per line. (Recall: A prime number is a number that is only divisible by itself and 1.) The code should ask the user if...
Write a Python program that asks the user to enter the monthly costs for the following...
Write a Python program that asks the user to enter the monthly costs for the following expenses incurred from operating his or her automobile: Loan payment Insurance Gas Oil Tires Maintenance Write a function that takes these six items as arguments and computes the total cost of these expenses. Write a main program that asks the user for these six items and calls your function. Print total monthly cost and the total annual cost for these expenses. Your function should...
In Python write a program that asks the user to enter the monthly costs for the...
In Python write a program that asks the user to enter the monthly costs for the following expenses incurred from operating his or her automobile: loan payment, insurance, gas, oil, tires, and maintenance the program should then display the total monthly cost of these expenses, and the total annual cost of these expenses. your program MUST have BOTH a main function AND a function named calcExpenses to calculate the expenses. DO NOT display the expenses inside of the calcExpenses function!!...
In PYTHON: Write a program that asks for a password from a user and checks if...
In PYTHON: Write a program that asks for a password from a user and checks if it satisfies the conditions: Contains at least one lowercase letter (a-z). Contains at least one uppercase letter (A-Z). Contains at least one digit (0-9). Minimum length 6 characters. Contains no spaces. If the password is valid, then the program prints “password accepted”. Otherwise, it keeps asking for more passwords from the user until a valid password is obtained. Hint: You might like to check...
Please write in python Use modular design to write a program that asks the user to...
Please write in python Use modular design to write a program that asks the user to enter his or her weight and the name of a planet. The program then outputs how much the user would weigh on that planet. The following table gives the factor by which the weight must be multiplied for each planet. PLANET CONVERSION FACTOR Mercury 0.4155 Venus 0.8975 Earth 1.0000 Moon 0.1660 Mars 0.3507 Jupiter 2.5374 Saturn 1.0677 Uranus 0.8947 Neptune 1.1794 Pluto 0.0899 The...
Using Python Write a program that does the following in order: 1.     Asks the user to enter...
Using Python Write a program that does the following in order: 1.     Asks the user to enter a name 2.     Asks the user to enter a number “gross income” 3.     Asks the user to enter a number “state tax rate” 4.     Calculates the “Federal Tax”, “FICA tax” and “State tax” 5.     Calculates the “estimated tax” and round the value to 2 decimal places 6.     Prints values for “name”, “gross income” and “estimated tax” The program should contain three additional variables to store the Federal tax, FICA...
Write a design algorithm and a python program which asks the user for the length of...
Write a design algorithm and a python program which asks the user for the length of the three sides of two triangles. It should compute the perimeter of the two triangles and display it. It should also display which triangle has the greater perimeter. If both have the same perimeter it should display that the perimeters are the same. Formula: Perimeter of triangleA = (side1A + side2A +side3A) See the 2 sample outputs. Enter side1 of TriangleA: 2 Enter side2...
Python English algorithm explanation Write a program that asks the user for the name of a...
Python English algorithm explanation Write a program that asks the user for the name of a file in the current directory. Then, open the file and process the content of the file. 1)If the file contains words that appear more than once, print “We found duplicates.” 2)If the file does not contain duplicate words, print “There are no duplicates.”
Python English algorithm explanation Write a program that asks the user for the name of a...
Python English algorithm explanation Write a program that asks the user for the name of a file in the current directory. Then, open the file and process the content of the file. 1)If the file contains words that appear more than once, print “We found duplicates.” 2)If the file does not contain duplicate words, print “There are no duplicates.”
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT