Question

In: Computer Science

Python What is the length of some_numbers? What is the sum of the values in some_numbers?...

Python

  1. What is the length of some_numbers?

  2. What is the sum of the values in some_numbers?

  3. How many courses is the student taking?

  4. What is the student's birthdate?

  5. How long is the course name of the second course in the student's list of courses?

some_numbers=[7,14,5,17,82]

student={"uin":123456789,
"name":"Josephina Student",
"birthdate": "01/01/2002",
"courses": ["CS111","BIOS100","ARST209","PHIL103"]}


course_catalog={
"ARST209": "The Art and Archaeology of the Ancient Near East",
"PHIL103": "Introduction to Ethics",
"CS111":"Program Design I",
"CS141":"Program Design II",
"BIOS100": "Biology of Cells and Organisms"
}

some_numbers=[7,14,5,17,82]

student={"uin":123456789,
"name":"Josephina Student",
"birthdate": "01/01/2002",
"courses": ["CS111","BIOS100","ARST209","PHIL103"]}


course_catalog={
"ARST209": "The Art and Archaeology of the Ancient Near East",
"PHIL103": "Introduction to Ethics",
"CS111":"Program Design I",
"CS141":"Program Design II",
"BIOS100": "Biology of Cells and Organisms"
}

Solutions

Expert Solution


some_numbers=[7,14,5,17,82] #create some_numbers list

student={"uin":123456789,
"name":"Josephina Student",
"birthdate": "01/01/2002",
"courses": ["CS111","BIOS100","ARST209","PHIL103"]} #create student dictionary


course_catalog={
"ARST209": "The Art and Archaeology of the Ancient Near East",
"PHIL103": "Introduction to Ethics",
"CS111":"Program Design I",
"CS141":"Program Design II",
"BIOS100": "Biology of Cells and Organisms"} #create course_catalog dictionary

sub=[] #declaration of empty list sub
#What is the length of some_numbers?
print("length of some_numbers is = ",len(some_numbers)) #print length of some_numbers
#What is the sum of the values in some_numbers?
print("sum of the values in some_numbers is = ",sum(some_numbers)) #addition of numbers in list some_numbers and print
#How many courses is the student taking?
print(len(student["courses"])," courses is the student taking") #print length of course list
#What is the student's birthdate?
print("Student birthdate is = ",student["birthdate"]) #print the value of birthdate in student dictionary

#How long is the course name of the second course in the student's list of courses?
for index in student: #for loop in student dictionary
if index == 'courses': #check student dictionary key is equal to courses
sub = student[index] # add list of courses in sub variable
  
second_course = sub[1] #get second course name in list
#print name of course and length of course name
print("course name of the second course in the student's list of courses ",second_course," = ",course_catalog[second_course]," length of course name is = ",len(course_catalog[second_course]))

==================================OUTPUT================================

==Please Upvote==


Related Solutions

What is the function and argument to calculate the sum of the values in the range...
What is the function and argument to calculate the sum of the values in the range D1:D50 for which in the adjacent value in the range A1:A50 equals “Senior” and the adjacent value in the range B1:B50 equals “B”? What is the function and argument to calculate the average of the cells in the range C1:C50 for which the adjacent cell in the range B1:B50 equals “B”? What is the function and argument to return the index number of the...
(Python) Implement a function to compute a sum that can compute sum for an arbitrary number...
(Python) Implement a function to compute a sum that can compute sum for an arbitrary number of input integers or float numbers. In other words, calls like this should all work: flexible_sum(x1, x2) # sum of two integer or float numbers or strings x1 and x2 flexible_sum(x1, x2, x3) # sum of 3 input parameters and can also handle a single input parameter, returning it unchanged and with the same type, i.e.:   flexible_sum(1) returns 1 and can accept an arbitrary...
What happens to future value of a lump sum if you increase the length of time...
What happens to future value of a lump sum if you increase the length of time involved (for example, going from 5 years to 10 years)?A) No Change to the future valueB) Future value increases.C) Future value decreasesD) The PV becomes negative. If the US T-Bill rate is 1.7%, the US expected inflation rate is 0.6%, the real rate of interest for Brazil is 2.2%, the default risk premium for Amazon is 0.9%, the maturity premium for Amazon debt is...
. What happens to future values as the length of time involved increases?   What happens to...
. What happens to future values as the length of time involved increases?   What happens to present values as the length of time involved increases?
For a given focal length, f, for what values of the object distance, do, will the...
For a given focal length, f, for what values of the object distance, do, will the image distance, di, be negative? (1/f)=(1/do)+(1/di)
As you increase the length of time involved, what happens to future values? What happens to...
As you increase the length of time involved, what happens to future values? What happens to present values?
in python You will be writing a program that can be used to sum up and...
in python You will be writing a program that can be used to sum up and report lab scores. Your program must allow a user to enter points values for the four parts of the problem solving process (0-5 points for each step), the code (0-20 points), and 3 partner ratings (0-10) points each. It should sum the points for each problem-solving step, the code, and the average of the three partner ratings and print out a string reporting the...
250 words As you increase the length of time involved, what happens to future values? What...
250 words As you increase the length of time involved, what happens to future values? What happens to present values?
Write a python program to sum the prime numbers existing in an array . For instance...
Write a python program to sum the prime numbers existing in an array . For instance , if A = [4, 7, 12, 3, 9] the output should be 10
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...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT