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

Write a Python program that computes certain values such as sum, product, max, min and average...
Write a Python program that computes certain values such as sum, product, max, min and average of any 5 given numbers along with the following requirements. Define a function that takes 5 numbers, calculates and returns the sum of the numbers. Define a function that takes 5 numbers, calculates and returns the product of the numbers. Define a function that takes 5 numbers, calculates and returns the average of the numbers. Must use the function you defined earlier to find...
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?
###### THIS SHOULD BE IN PYTHON Calculate the sum of cubes. If the input is x,...
###### THIS SHOULD BE IN PYTHON Calculate the sum of cubes. If the input is x, the sum of cubes is equal to: 13 + 23 + ... + x3 Take input for the number of cubes to sum. No error checking is needed. Specifically, you may assume that the input is always a positive integer Here are some sample runs: Enter how many cubes to sum: 1    1    Enter how many cubes to sum: 3 36 Enter...
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)
for Python 3 Write a python program that Creates a list that has these values in...
for Python 3 Write a python program that Creates a list that has these values in this order, 'Python', 'JavaScript', and 'PHP' Define a displayMyClasses function that sorts the list and then displays each item on the list, one per line, in sorted order. Also, number the displayed list as shown in the "Running a Sample Program" shown below. Define a guessNext function that selects a random element from the list and returns it to the call of the function....
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...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT