Lab3.ipynb - Colaboratory
Lab3.ipynb - Colaboratory
ipynb - Colaboratory
name_1 = input("Please enter your first name: ") #get first name
name_2 = input("Please enter your family name: ") #get family name
id = input("Please enter your student id: ") #get student id
Ulearn = [] #create list
Ulearn.append(f'{name_1}') #add item to the end of the list
Ulearn.append(f'{name_2}')
Ulearn.append(f'{id}')
name1 = [] #create list
for i in Ulearn[0]: #read every character in name_1 with index 0
name1.append(i)
first_name = name1[0].lower() #get all lowercase string
name2 = Ulearn[1]
family_name = name2[0:3].lower() #use indices to get firt to third value
studentid = Ulearn[2]
number = []
for c in studentid:
number.append(c)
length = len(number)
digits = studentid[length - 4:]
Ulearn_id = "_".join([first_name, family_name, digits]) #concatenates a list of string with underscore
print("Your Ulearn login id is: ",f'{Ulearn_id}')
num_1 = input("Please enter number 1: ") #get number
num_2 = input("Please enter number 2: ")
num_3 = input("Please enter number 3: ")
num_4 = input("Please enter number 4: ")
num_list = [] #create list
num_list.append(num_1) #add number to the end of the list
num_list.append(num_2)
num_list.append(num_3)
num_list.append(num_4)
Max = max(num_list) #get largest number from num_list
num_list.remove(Max) #remove largest number from num_list
Min = min(num_list) #get smallest number from num_list
num_list.remove(Min) #remove smallest number from num_list
Max2 = max(num_list) #find second largest number
Min2 = min(num_list) #find second smallest number
as_order = f"{Min}\t{Min2}\t{Max2}\t{Max}" #Add space between integers
de_order = f"{Max}\t{Max2}\t{Min2}\t{Min}" #Add space between integers
print(f'The ascedning order is: {as_order}')
print(f'The·descending·order·is:·{de_order}')
https://colab.research.google.com/drive/1D0qM9c3T6XF5G0ONPAhopB3uRl_HP_vK#scrollTo=kGM5isNuBnKr&printMode=true 1/2
2/13/23, 11:03 PM Lab3.ipynb - Colaboratory
https://colab.research.google.com/drive/1D0qM9c3T6XF5G0ONPAhopB3uRl_HP_vK#scrollTo=kGM5isNuBnKr&printMode=true 2/2