In: Computer Science
At a university, each student is assigned a system login name, which the student uses to log into the campus computer system. Write the code that generates system login names for students. You will use the following algorithm to generate a login name:
For example, if a student’s name is Amanda Spencer, and her ID number is ENG6721, her login name would be AmaSpe721. You decide to write a function named get_login_namethat accepts a student’s first name, last name, and ID number as arguments, and returns the student’s login name as a string.
(ON PYTHON IDLE 3.7.2)
output:
source code:
def get_login_name(f_name,l_name,id_number):
f_cal=len(f_name)
l_cal=len(l_name)
id_cal=len(id_number)
k=" "
if(f_cal<=3 and l_cal>3 and id_cal>3):
k=f_name+l_name[0:3]+id_number[-3:]
elif(f_cal>3 and l_cal<=3 and
id_cal>3):
k=f_name[0:3]+l_name+id_number[-3:]
elif(f_cal>3 and l_cal>3 and
id_cal<=3):
k=f_name[0:3]+l_name[0:3]+id_number
elif(f_cal<=3 and l_cal<=3 and
id_cal>3):
k=f_name+l_name+id_number[-3:]
elif(f_cal>3 and l_cal<=3 and
id_cal<=3):
k=f_name[0:3]+l_name+id_number
elif(f_cal<=3 and l_cal>3 and
id_cal<=3):
k=f_name+l_name[0:3]+id_number
elif(f_cal<=3 and l_cal<=3 and
id_cal<=3):
k=f_name+l_name+id_number
elif(f_cal>3 and l_cal>3 and id_cal>3):
k=f_name[0:3]+l_name[0:3]+id_number[-3:]
return k
f_name=input("Enter your first name")
l_name=input("Enter your first name")
id_number=input("Enter your first name")
login_name=get_login_name(f_name,l_name,id_number)
print(login_name)
if you have any doubts comment below.....