0% found this document useful (0 votes)
7 views

Coding Python Homework

Uploaded by

aashiraasiingh
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

Coding Python Homework

Uploaded by

aashiraasiingh
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

# -*- coding: utf-8 -*-

"""

HW 1. Using this list a = [1, 4, 9, 16, 25, 36, 49, 64, 81, 100]
Output 2 separate lists with even and odd numbers separated.

HW 2. Take user input to build a list containing marks of 5 subjects (Out of 100).
a) Calculate the average marks.
b) Judge 'over all performance' in each subject with output depending on:
score > 50 -> Needs improvement
score > 70 -> Can do better
score > 80 -> Bravo! Try harder
score > 90 -> Excellent

HW 3. Take the user input value n to stand for the number of inputs. Next, Collect input
numbers from user n number of times and sort into different lists. The final output
being 4 separate lists each representing input values completely divisible by 2,3,5 and
one for exceptions.

HW 4.Count the number of times a substring appears in a string.


Eg: Emma is a good writer. Emma works for Sterling Editorial.
Subsrtng Emma appears : 2 times
Hint: String methods

HW 5. Create a list of students names if they have the parent permission card
to be included in a field trip. Use n to represent the number of students. Collect
n number of student names and permission status ('Yes' or 'No'). Generate 2 final lists
for the students separating into batches allowed and not allowed.

HW 6. Write a python program to interchange first and last elements in a list.

HW 7. Find the smallest and largest element in the list.

HW 8. Rearrange the values in a list in ascending order.

test_list = [1, 9, 5, 6, 3, 4, 5]
count = len(test_list)
for i in range(0,count-1):
for j in range(i+1,count):
if test_list[i]>test_list[j]:
temp = test_list[i]
test_list[i]=test_list[j]
test_list[j] = temp
print(test_list)

HW 9. Find = sum pairs equal to n from the elements in a list


Input :
test_list = [1, 9, 5, 5, 7]
n = 10
Output : 1, 9
5, 5

HW 10. Rock paper Scissors

import random
play = 'Y'

while (play == 'Y'):

val = input("Enter Choice: \n 1. Rock \n 2. Paper \n 3. scissor\n\n")

if val == "1":
n = random.choice([2,3])
if n == 2:
print("Computer's choice is Paper \n Rock Vs. Paper \n Paper Wins => Computer Wins\
n")
else:
print("Computer's choice is Scissor \n Rock Vs. Scissor \n Scissor Wins => Player Wins\
n")
"""

You might also like