A))
(Ransom Note Problem) in python
A kidnapper kidnaps you and writes a ransom note. He does not write it by hand to avoid having his hand writing being recognized, so he uses a magazine to create a ransom note. We need to find out, given the ransom string and magazine string, is it possible to create a given ransom note. The kidnapper can use individual characters of words.
Here is how your program should work to simulate the ransom problem, USING LISTS, no dictionaries:
Example: If the magazine string is “programming problems are weird”
If the ransom note is: “no see” your program should print true as all the characters in “no see” exist in the magazine string.
If the ransom note is “no show” your program should print false as not all the characters in “no show” exist in the magazine string as you can see the character ‘h’ does not exist.
B)) Short one
Write Python code to define a class called Student.
The Student class should have the following private fields:
The Student class should have the following methods:
In the same file, write a main function to test the functionality of the Student class.
Code for Question - A: Ransom Note Problem in python.
# Taking Magazine text from User
magazine=input("Enter Magazine Text: ")
# Taking ransom text from User
ransom=input("Enter Ransom text: ")
# Running the loop for Small Alphabets a to z
# a=97 ........................ z=122
for i in range(97,123):
c = chr(i) # Type casting - Getting alphabet using ascii value
# Check character count in magazine and ransom text
# if count of character in ransom less then count of character in
magazine
# If condition accepted and print False and loop will break
if(magazine.count(c)<ransom.count(c)):
print('False')
break
# For-Else Loop
# If loop runs without any break else condition will be
executed
else:
print('True')
Code Screenshot:

Output Screenshots:


Code for Question -B : Write Python code to define a class called Student.
# Student class to store Students data
class Student:
# Class intialization method with arguments
def __init__(self,name='', attend=0, grades=[]):
# Assigning to respected values
self.name = name
self.attend = attend
self.grades = grades
# Method to get name from Class instance object
def get_name(self):
return self.name
# Method to add attendance to Class instance object
def attendClass(self):
self.attend += 1
# Method to add grades to Class instance object
def addGrade(self, grade):
self.grades.append(grade)
def __str__(self):
result = 'Name: ' + self.name + '\n'
result += 'Number of classes attending: ' + str(self.attend) +
'\n'
result += 'Grades are: ' + str(self.grades)
return result
# Main function
if __name__=="__main__":
# Creating Class instance and passign name string
s = Student(name='Ronaldo')
# Increasing the class attendance
s.attendClass()
# Adding Grades
s.addGrade(97)
# Increasing the class attendance
s.attendClass()
# Adding Grades
s.addGrade(92)
# Printing Instance Values using class method
print(s.__str__())
Code Screenshots:


Output Screenshot:

Note: If you any Quiries, ask me in comments...
Please vote up. your vote is more valuable to me.
A)) (Ransom Note Problem) in python A kidnapper kidnaps you and writes a ransom note. He...
For each problem, you must: Write a Python program Test, debug, and execute the Python program Save your program in a .py file and submit your commented code to your Student Page. Note regarding comments: For every class, method or function you create, you must provide a brief description of the what the code does as well as the specific details of the interface (input and output) of the function or method. (25 pts.) Write a program that reads in...
Java - In NetBeans IDE: • Create a class called Student which stores: - the name of the student - the grade of the student • Write a main method that asks the user for the name of the input file and the name of the output file. Main should open the input file for reading . It should read in the first and last name of each student into the Student’s name field. It should read the grade into...
Create a java class for an object called Student which contains the following private attributes: a given name (String), a surname (family name) (String), a student ID number (an 8 digit number, String or int) which does not begin with 0. There should be a constructor that accepts two name parameters (given and family names) and an overloaded constructor accepting two name parameters and a student number. The constructor taking two parameters should assign a random number of 8 digits....
Using Python: Par 1. You will define Student class with the following attributes: CWID: the student’s CWID FirstName: the student’s first name LastName: the student’s last name Gender: the student’s gender (‘M’ or ‘F’) BirthDate: the student’s date of birth (e.g. ‘03/14/1999’) ClassID: the class id that the student took ClassDate: the date when the student took the class (e.g. ‘01/26/2018’) Grade: the student’s grade for the class In addition, you will do the following tasks: Implement a set of...
c++ I need help! create Student.h In this class, you are provided with a class skeleton for the Student type. This type should contain two member variables: a string called name a vector of doubles called grades Additionally, you should declare the following functions: A constructor which accepts a single string parameter called name A void function, addGrade which accepts a single double parameter and adds it to the grades vector A function which accepts no parameters and returns the...
A) Please implement a Python script to define a student class with the following attributes (instance attributes): cwid: student’s CWID first_name : student’s first name last_name: student’s last name gender: student’s gender gpa: student’s gpa Please make these attributes as private ones so they have to be accessed via getter/setter methods or property. For this purpose, please define a getter/setter method and property for each of the attributes. Another thing you need to do is to define a constructor that...
PYTHON PROGRAMMING Instructions: You are responsible for writing a program that allows a user to do one of five things at a time: 1. Add students to database. • There should be no duplicate students. If student already exists, do not add the data again; print a message informing student already exists in database. • Enter name, age, and address. 2. Search for students in the database by name. • User enters student name to search • Show student name,...
In this assignment you are asked to write a python program to maintain the Student enrollment in to a class and points scored by him in a class. You need to do it by using a List of Tuples What you need to do? 1. You need to repeatedly display this menu to the user 1. Enroll into Class 2. Drop from Class 3. Calculate average of grades for a course 4. View all Students 5. Exit 2. Ask the...
In Python In this programming assignment, you will do multiple programming exercises, and eventually develop a Python application that can calculate student course grades. (6 points) Write a program called p2-1.py to: (1) create a list and add integer numbers from 1 to 100 to the list; (2) calculate the average value of all numbers in the list; and (3) print the result (screenshots). (8 points) Write a program called p2-2.py to: (1) allow a user to define how many...
Java program
Program: Grade Stats In this program you will create a utility to calculate and display various statistics about the grades of a class. In particular, you will read a CSV file (comma separated value) that stores the grades for a class, and then print out various statistics, either for the whole class, individual assignments, or individual students Things you will learn Robustly parsing simple text files Defining your own objects and using them in a program Handling multiple...