SlideShare a Scribd company logo
For any help regarding Python Homework Help
Visit :- https://www.pythonhomeworkhelp.com/ ,
Email :- support@pythonhomeworkhelp.com or
Call us at :- +1 678 648 4277
Python Homework Help
Problem 1 - Sorting a List
Write a program that asks the user to enter 10 (positive) numbers. The program should then print the numbers in
sorted order, from biggest to smallest.
To do this, first write a function that takes a list and finds the largest element. It then 1) deletes that element from
the list and 2) returns that element.
Hint: You will need to store two variables in this function: the biggest number you've seen so far (remember to
initially set this to 0), and its position. Then iterate over the list, and for each element, check if it's bigger than the
biggest number you've seen so far. If it is, change both variables (remember to change BOTH)!
So in your main program, you'll have to keep calling this function (in a loop) until the list is empty and keep
printing the number that is returned.
Problem 2 – Report card with GPA
Write a program where the user can enter each of his grades, after which the program prints out a report card with
GPA. Remember to ask the user how many classes he took. Example output is below.
Python Homework Help
Hints: You’ll want to use a for loop, and you’ll probably want to keep two lists, one for names and one for grades.
Remember, add to lists with append.
Python Homework Help
# sorting.py
# Example solution for Lab 5, problem 1
#
# Aseem Kishore
#
# 6.189 - Intro to Python
# IAP 2008 - Class 4
L = []
for i in range(10):
a = int(raw_input("Please enter
a number. "))
# DON'T do this: L[i] = a
L.append(a)
def find_largest(L):
maximum = 0
index = 0
for i in range(len(L)):
if L[i] > maximum:
maximum = L[i]
index = i
del L[index]
return maximum
# this is fine: while len(L) > 0:
for i in range(10):
print find_largest(L),
Python Homework Help
# reportcard.py
# Example solution for Lab 5,
problem 2
#
# Aseem Kishore
#
# 6.189 - Intro to Python
# IAP 2008 - Class 4
# Helper function that takes a list of
grades and returns the GPA.
# Remember that average (mean) is
the sum divided by the number of
grades.
# Just like in math, you sum first,
THEN divide -- order of operations.
# Don't make the mistake of dividing
inside the loop!
def calculate_gpa(grades):
running_sum = 0
for grade in grades:
running_sum = running_sum +
grade
return float(running_sum) /
len(grades) # remember we want
decimals, so
# use float(...)
Python Homework Help
# Main program code
class_names = []
class_grades = []
number_classes = int(raw_input("How many classes did you take? "))
print # this prints a blank line
# Now we're going to ask the same two questions over and over --> loop!
# Since we know how many times we're looping (number_classes), we use for.
# Note that we need a variable name for the "for", but we don't use it here.
# What does range return? A list of numbers, from 0 to number_classes.
for arbitrary_variable_name in range(number_classes):
name = raw_input("What is the name of this class? ")
grade = int(raw_input("What grade did you get? "))
class_names.append(name) # add the two things to our lists...
class_grades.append(grade)
print # blank line
# Now we'll print the report card. The report card should look like:
# class name - grade
# Over and over again --> loop! How many of these lines? number_classes
print "Report card:"
print
for class_number in range(number_classes):
Python Homework Help
print
class_names[class_number],
"-",
class_grades[class_number]
print
print "Term GPA:",
calculate_gpa(class_grades)
Python Homework Help
Ad

Recommended

Python Exam (Questions with Solutions Done By Live Exam Helper Experts)
Python Exam (Questions with Solutions Done By Live Exam Helper Experts)
Live Exam Helper
 
Sorting Lists and Calculating GPA Using python programming
Sorting Lists and Calculating GPA Using python programming
programmingassignmentexperts.com
 
Python.pptx
Python.pptx
AshaS74
 
Python Lab manual program for BE First semester (all department
Python Lab manual program for BE First semester (all department
Nazeer Wahab
 
Python for High School Programmers
Python for High School Programmers
Siva Arunachalam
 
xii cs practicals
xii cs practicals
JaswinderKaurSarao
 
ANSHUL RANA - PROGRAM FILE.pptx
ANSHUL RANA - PROGRAM FILE.pptx
jeyel85227
 
Learn python
Learn python
mocninja
 
Raspberry Pi - Lecture 5 Python for Raspberry Pi
Raspberry Pi - Lecture 5 Python for Raspberry Pi
Mohamed Abdallah
 
Basic python laboratoty_ PSPP Manual .docx
Basic python laboratoty_ PSPP Manual .docx
Kirubaburi R
 
solution-of-practicals-class-xii-comp.-sci.-083-2021-22 (1).pdf
solution-of-practicals-class-xii-comp.-sci.-083-2021-22 (1).pdf
parthp5150s
 
pyton Notes9
pyton Notes9
Amba Research
 
Python Lab Manual
Python Lab Manual
Bobby Murugesan
 
Python program For O level Practical
Python program For O level Practical
pavitrakumar18
 
File Programs with Solutions on python.pptx
File Programs with Solutions on python.pptx
yogeshprasanna313
 
advanced python for those who have beginner level experience with python
advanced python for those who have beginner level experience with python
barmansneha1204
 
Advanced Python after beginner python for intermediate learners
Advanced Python after beginner python for intermediate learners
barmansneha1204
 
Master Python in 15 Days.pdf
Master Python in 15 Days.pdf
JorgeTorres560505
 
Python programming workshop session 3
Python programming workshop session 3
Abdul Haseeb
 
if, while and for in Python
if, while and for in Python
PranavSB
 
03 standard Data Types
03 standard Data Types
Ebad Qureshi
 
Practice_Exercises_Data_Structures.pptx
Practice_Exercises_Data_Structures.pptx
Rahul Borate
 
Python in One Shot.docx
Python in One Shot.docx
DeepakSingh710536
 
Python in one shot
Python in one shot
Gulshan76
 
Practice_Exercises_Control_Flow.pptx
Practice_Exercises_Control_Flow.pptx
Rahul Borate
 
Practical File Grade 12.pdf
Practical File Grade 12.pdf
dipanshujoshi8869
 
xii cs practicals class 12 computer science.pdf
xii cs practicals class 12 computer science.pdf
gmaiihghtg
 
Python summer course play with python (lab1)
Python summer course play with python (lab1)
iloveallahsomuch
 
Python Homework Help
Python Homework Help
Python Homework Help
 
Python Homework Help
Python Homework Help
Python Homework Help
 

More Related Content

Similar to Python Homework Help (20)

Raspberry Pi - Lecture 5 Python for Raspberry Pi
Raspberry Pi - Lecture 5 Python for Raspberry Pi
Mohamed Abdallah
 
Basic python laboratoty_ PSPP Manual .docx
Basic python laboratoty_ PSPP Manual .docx
Kirubaburi R
 
solution-of-practicals-class-xii-comp.-sci.-083-2021-22 (1).pdf
solution-of-practicals-class-xii-comp.-sci.-083-2021-22 (1).pdf
parthp5150s
 
pyton Notes9
pyton Notes9
Amba Research
 
Python Lab Manual
Python Lab Manual
Bobby Murugesan
 
Python program For O level Practical
Python program For O level Practical
pavitrakumar18
 
File Programs with Solutions on python.pptx
File Programs with Solutions on python.pptx
yogeshprasanna313
 
advanced python for those who have beginner level experience with python
advanced python for those who have beginner level experience with python
barmansneha1204
 
Advanced Python after beginner python for intermediate learners
Advanced Python after beginner python for intermediate learners
barmansneha1204
 
Master Python in 15 Days.pdf
Master Python in 15 Days.pdf
JorgeTorres560505
 
Python programming workshop session 3
Python programming workshop session 3
Abdul Haseeb
 
if, while and for in Python
if, while and for in Python
PranavSB
 
03 standard Data Types
03 standard Data Types
Ebad Qureshi
 
Practice_Exercises_Data_Structures.pptx
Practice_Exercises_Data_Structures.pptx
Rahul Borate
 
Python in One Shot.docx
Python in One Shot.docx
DeepakSingh710536
 
Python in one shot
Python in one shot
Gulshan76
 
Practice_Exercises_Control_Flow.pptx
Practice_Exercises_Control_Flow.pptx
Rahul Borate
 
Practical File Grade 12.pdf
Practical File Grade 12.pdf
dipanshujoshi8869
 
xii cs practicals class 12 computer science.pdf
xii cs practicals class 12 computer science.pdf
gmaiihghtg
 
Python summer course play with python (lab1)
Python summer course play with python (lab1)
iloveallahsomuch
 
Raspberry Pi - Lecture 5 Python for Raspberry Pi
Raspberry Pi - Lecture 5 Python for Raspberry Pi
Mohamed Abdallah
 
Basic python laboratoty_ PSPP Manual .docx
Basic python laboratoty_ PSPP Manual .docx
Kirubaburi R
 
solution-of-practicals-class-xii-comp.-sci.-083-2021-22 (1).pdf
solution-of-practicals-class-xii-comp.-sci.-083-2021-22 (1).pdf
parthp5150s
 
Python program For O level Practical
Python program For O level Practical
pavitrakumar18
 
File Programs with Solutions on python.pptx
File Programs with Solutions on python.pptx
yogeshprasanna313
 
advanced python for those who have beginner level experience with python
advanced python for those who have beginner level experience with python
barmansneha1204
 
Advanced Python after beginner python for intermediate learners
Advanced Python after beginner python for intermediate learners
barmansneha1204
 
Master Python in 15 Days.pdf
Master Python in 15 Days.pdf
JorgeTorres560505
 
Python programming workshop session 3
Python programming workshop session 3
Abdul Haseeb
 
if, while and for in Python
if, while and for in Python
PranavSB
 
03 standard Data Types
03 standard Data Types
Ebad Qureshi
 
Practice_Exercises_Data_Structures.pptx
Practice_Exercises_Data_Structures.pptx
Rahul Borate
 
Python in one shot
Python in one shot
Gulshan76
 
Practice_Exercises_Control_Flow.pptx
Practice_Exercises_Control_Flow.pptx
Rahul Borate
 
xii cs practicals class 12 computer science.pdf
xii cs practicals class 12 computer science.pdf
gmaiihghtg
 
Python summer course play with python (lab1)
Python summer course play with python (lab1)
iloveallahsomuch
 

More from Python Homework Help (20)

Python Homework Help
Python Homework Help
Python Homework Help
 
Python Homework Help
Python Homework Help
Python Homework Help
 
Python Homework Help
Python Homework Help
Python Homework Help
 
Python Homework Help
Python Homework Help
Python Homework Help
 
Python Homework Help
Python Homework Help
Python Homework Help
 
Complete my Python Homework
Complete my Python Homework
Python Homework Help
 
Introduction to Python Dictionary.pptx
Introduction to Python Dictionary.pptx
Python Homework Help
 
Basic Python Programming.pptx
Basic Python Programming.pptx
Python Homework Help
 
Introduction to Python Programming.pptx
Introduction to Python Programming.pptx
Python Homework Help
 
Introduction to Python Programming.pptx
Introduction to Python Programming.pptx
Python Homework Help
 
Introduction to Python Programming.pptx
Introduction to Python Programming.pptx
Python Homework Help
 
Introduction to Python Programming.pptx
Introduction to Python Programming.pptx
Python Homework Help
 
Introduction to Python Programming.pptx
Introduction to Python Programming.pptx
Python Homework Help
 
Introduction to Python Programming.pptx
Introduction to Python Programming.pptx
Python Homework Help
 
Introduction to Python Programming.pptx
Introduction to Python Programming.pptx
Python Homework Help
 
Python Homework Help
Python Homework Help
Python Homework Help
 
Python Homework Help
Python Homework Help
Python Homework Help
 
Python Programming Homework Help.pptx
Python Programming Homework Help.pptx
Python Homework Help
 
Quality Python Homework Help
Quality Python Homework Help
Python Homework Help
 
Perfect Python Homework Help
Perfect Python Homework Help
Python Homework Help
 
Introduction to Python Dictionary.pptx
Introduction to Python Dictionary.pptx
Python Homework Help
 
Introduction to Python Programming.pptx
Introduction to Python Programming.pptx
Python Homework Help
 
Introduction to Python Programming.pptx
Introduction to Python Programming.pptx
Python Homework Help
 
Introduction to Python Programming.pptx
Introduction to Python Programming.pptx
Python Homework Help
 
Introduction to Python Programming.pptx
Introduction to Python Programming.pptx
Python Homework Help
 
Introduction to Python Programming.pptx
Introduction to Python Programming.pptx
Python Homework Help
 
Introduction to Python Programming.pptx
Introduction to Python Programming.pptx
Python Homework Help
 
Introduction to Python Programming.pptx
Introduction to Python Programming.pptx
Python Homework Help
 
Python Programming Homework Help.pptx
Python Programming Homework Help.pptx
Python Homework Help
 
Ad

Recently uploaded (20)

Community Health Nursing Approaches, Concepts, Roles & Responsibilities – Uni...
Community Health Nursing Approaches, Concepts, Roles & Responsibilities – Uni...
RAKESH SAJJAN
 
K12 Tableau User Group virtual event June 18, 2025
K12 Tableau User Group virtual event June 18, 2025
dogden2
 
Sustainable Innovation with Immersive Learning
Sustainable Innovation with Immersive Learning
Leonel Morgado
 
IIT KGP Quiz Week 2024 Sports Quiz (Prelims + Finals)
IIT KGP Quiz Week 2024 Sports Quiz (Prelims + Finals)
IIT Kharagpur Quiz Club
 
Pests of Maize: An comprehensive overview.pptx
Pests of Maize: An comprehensive overview.pptx
Arshad Shaikh
 
Chalukyas of Gujrat, Solanki Dynasty NEP.pptx
Chalukyas of Gujrat, Solanki Dynasty NEP.pptx
Dr. Ravi Shankar Arya Mahila P. G. College, Banaras Hindu University, Varanasi, India.
 
Values Education 10 Quarter 1 Module .pptx
Values Education 10 Quarter 1 Module .pptx
JBPafin
 
Health Care Planning and Organization of Health Care at Various Levels – Unit...
Health Care Planning and Organization of Health Care at Various Levels – Unit...
RAKESH SAJJAN
 
How to Manage Different Customer Addresses in Odoo 18 Accounting
How to Manage Different Customer Addresses in Odoo 18 Accounting
Celine George
 
Paper 108 | Thoreau’s Influence on Gandhi: The Evolution of Civil Disobedience
Paper 108 | Thoreau’s Influence on Gandhi: The Evolution of Civil Disobedience
Rajdeep Bavaliya
 
Paper 107 | From Watchdog to Lapdog: Ishiguro’s Fiction and the Rise of “Godi...
Paper 107 | From Watchdog to Lapdog: Ishiguro’s Fiction and the Rise of “Godi...
Rajdeep Bavaliya
 
This is why students from these 44 institutions have not received National Se...
This is why students from these 44 institutions have not received National Se...
Kweku Zurek
 
University of Ghana Cracks Down on Misconduct: Over 100 Students Sanctioned
University of Ghana Cracks Down on Misconduct: Over 100 Students Sanctioned
Kweku Zurek
 
How to Implement Least Package Removal Strategy in Odoo 18 Inventory
How to Implement Least Package Removal Strategy in Odoo 18 Inventory
Celine George
 
Communicable Diseases and National Health Programs – Unit 9 | B.Sc Nursing 5t...
Communicable Diseases and National Health Programs – Unit 9 | B.Sc Nursing 5t...
RAKESH SAJJAN
 
GEOGRAPHY-Study Material [ Class 10th] .pdf
GEOGRAPHY-Study Material [ Class 10th] .pdf
SHERAZ AHMAD LONE
 
Tanja Vujicic - PISA for Schools contact Info
Tanja Vujicic - PISA for Schools contact Info
EduSkills OECD
 
ROLE PLAY: FIRST AID -CPR & RECOVERY POSITION.pptx
ROLE PLAY: FIRST AID -CPR & RECOVERY POSITION.pptx
Belicia R.S
 
Nutrition Assessment and Nutrition Education – Unit 4 | B.Sc Nursing 5th Seme...
Nutrition Assessment and Nutrition Education – Unit 4 | B.Sc Nursing 5th Seme...
RAKESH SAJJAN
 
The Man In The Back – Exceptional Delaware.pdf
The Man In The Back – Exceptional Delaware.pdf
dennisongomezk
 
Community Health Nursing Approaches, Concepts, Roles & Responsibilities – Uni...
Community Health Nursing Approaches, Concepts, Roles & Responsibilities – Uni...
RAKESH SAJJAN
 
K12 Tableau User Group virtual event June 18, 2025
K12 Tableau User Group virtual event June 18, 2025
dogden2
 
Sustainable Innovation with Immersive Learning
Sustainable Innovation with Immersive Learning
Leonel Morgado
 
IIT KGP Quiz Week 2024 Sports Quiz (Prelims + Finals)
IIT KGP Quiz Week 2024 Sports Quiz (Prelims + Finals)
IIT Kharagpur Quiz Club
 
Pests of Maize: An comprehensive overview.pptx
Pests of Maize: An comprehensive overview.pptx
Arshad Shaikh
 
Values Education 10 Quarter 1 Module .pptx
Values Education 10 Quarter 1 Module .pptx
JBPafin
 
Health Care Planning and Organization of Health Care at Various Levels – Unit...
Health Care Planning and Organization of Health Care at Various Levels – Unit...
RAKESH SAJJAN
 
How to Manage Different Customer Addresses in Odoo 18 Accounting
How to Manage Different Customer Addresses in Odoo 18 Accounting
Celine George
 
Paper 108 | Thoreau’s Influence on Gandhi: The Evolution of Civil Disobedience
Paper 108 | Thoreau’s Influence on Gandhi: The Evolution of Civil Disobedience
Rajdeep Bavaliya
 
Paper 107 | From Watchdog to Lapdog: Ishiguro’s Fiction and the Rise of “Godi...
Paper 107 | From Watchdog to Lapdog: Ishiguro’s Fiction and the Rise of “Godi...
Rajdeep Bavaliya
 
This is why students from these 44 institutions have not received National Se...
This is why students from these 44 institutions have not received National Se...
Kweku Zurek
 
University of Ghana Cracks Down on Misconduct: Over 100 Students Sanctioned
University of Ghana Cracks Down on Misconduct: Over 100 Students Sanctioned
Kweku Zurek
 
How to Implement Least Package Removal Strategy in Odoo 18 Inventory
How to Implement Least Package Removal Strategy in Odoo 18 Inventory
Celine George
 
Communicable Diseases and National Health Programs – Unit 9 | B.Sc Nursing 5t...
Communicable Diseases and National Health Programs – Unit 9 | B.Sc Nursing 5t...
RAKESH SAJJAN
 
GEOGRAPHY-Study Material [ Class 10th] .pdf
GEOGRAPHY-Study Material [ Class 10th] .pdf
SHERAZ AHMAD LONE
 
Tanja Vujicic - PISA for Schools contact Info
Tanja Vujicic - PISA for Schools contact Info
EduSkills OECD
 
ROLE PLAY: FIRST AID -CPR & RECOVERY POSITION.pptx
ROLE PLAY: FIRST AID -CPR & RECOVERY POSITION.pptx
Belicia R.S
 
Nutrition Assessment and Nutrition Education – Unit 4 | B.Sc Nursing 5th Seme...
Nutrition Assessment and Nutrition Education – Unit 4 | B.Sc Nursing 5th Seme...
RAKESH SAJJAN
 
The Man In The Back – Exceptional Delaware.pdf
The Man In The Back – Exceptional Delaware.pdf
dennisongomezk
 
Ad

Python Homework Help

  • 1. For any help regarding Python Homework Help Visit :- https://www.pythonhomeworkhelp.com/ , Email :- [email protected] or Call us at :- +1 678 648 4277 Python Homework Help
  • 2. Problem 1 - Sorting a List Write a program that asks the user to enter 10 (positive) numbers. The program should then print the numbers in sorted order, from biggest to smallest. To do this, first write a function that takes a list and finds the largest element. It then 1) deletes that element from the list and 2) returns that element. Hint: You will need to store two variables in this function: the biggest number you've seen so far (remember to initially set this to 0), and its position. Then iterate over the list, and for each element, check if it's bigger than the biggest number you've seen so far. If it is, change both variables (remember to change BOTH)! So in your main program, you'll have to keep calling this function (in a loop) until the list is empty and keep printing the number that is returned. Problem 2 – Report card with GPA Write a program where the user can enter each of his grades, after which the program prints out a report card with GPA. Remember to ask the user how many classes he took. Example output is below. Python Homework Help
  • 3. Hints: You’ll want to use a for loop, and you’ll probably want to keep two lists, one for names and one for grades. Remember, add to lists with append. Python Homework Help
  • 4. # sorting.py # Example solution for Lab 5, problem 1 # # Aseem Kishore # # 6.189 - Intro to Python # IAP 2008 - Class 4 L = [] for i in range(10): a = int(raw_input("Please enter a number. ")) # DON'T do this: L[i] = a L.append(a) def find_largest(L): maximum = 0 index = 0 for i in range(len(L)): if L[i] > maximum: maximum = L[i] index = i del L[index] return maximum # this is fine: while len(L) > 0: for i in range(10): print find_largest(L), Python Homework Help
  • 5. # reportcard.py # Example solution for Lab 5, problem 2 # # Aseem Kishore # # 6.189 - Intro to Python # IAP 2008 - Class 4 # Helper function that takes a list of grades and returns the GPA. # Remember that average (mean) is the sum divided by the number of grades. # Just like in math, you sum first, THEN divide -- order of operations. # Don't make the mistake of dividing inside the loop! def calculate_gpa(grades): running_sum = 0 for grade in grades: running_sum = running_sum + grade return float(running_sum) / len(grades) # remember we want decimals, so # use float(...) Python Homework Help
  • 6. # Main program code class_names = [] class_grades = [] number_classes = int(raw_input("How many classes did you take? ")) print # this prints a blank line # Now we're going to ask the same two questions over and over --> loop! # Since we know how many times we're looping (number_classes), we use for. # Note that we need a variable name for the "for", but we don't use it here. # What does range return? A list of numbers, from 0 to number_classes. for arbitrary_variable_name in range(number_classes): name = raw_input("What is the name of this class? ") grade = int(raw_input("What grade did you get? ")) class_names.append(name) # add the two things to our lists... class_grades.append(grade) print # blank line # Now we'll print the report card. The report card should look like: # class name - grade # Over and over again --> loop! How many of these lines? number_classes print "Report card:" print for class_number in range(number_classes): Python Homework Help