Question

40pts) Given the following code segment. mSwer= input(Enter age: ) ile answer != q : try: print(int(answer) ) answer inpu

0 0
Add a comment Improve this question Transcribed image text
Answer #1
8)
20 => 20
17 => 17
2a => Invalid age
29 => this input is ignored by the program
q  => this input is ignored by the program

9)
class Student:
    def __init__(self, name, classList):
        self.name = name
        self.classList = classList

    def search(self, className):
        if className in self.classList:
            print("found")
        else:
            print("not found")

    def print(self):
        print("Name: " + self.name)
        print("Classes:")
        for cls in self.classList:
            print(cls)


def main():
    s = Student("Sam", ["CIS 40", "HIST 1A", "MATH 10"])
    s.search("CIS 40")
    s.print()


main()
Add a comment
Know the answer?
Add Answer to:
40pts) Given the following code segment. mSwer= input("Enter age: ") ile answer != 'q' : try:...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • /*--------------------------------------------------------------------------- // AUTHOR: // SPECIFICATION: This program is for practicing the use of classes, constructors, //...

    /*--------------------------------------------------------------------------- // AUTHOR: // SPECIFICATION: This program is for practicing the use of classes, constructors, // helper methods, and the this operator. // INSTRUCTIONS: Read the following code skeleton and add your own code // according to the comments //-------------------------------------------------------------------------*/ import java.util.Scanner; public class { public static void main(String[] args) { // Let's make two students using all two constructors // Write code to create a new student alice using constructor #1 //--> Student alice = // Write code to...

  • 1. Do the following a. Write a class Student that has the following attributes: - name:...

    1. Do the following a. Write a class Student that has the following attributes: - name: String, the student's name ("Last, First" format) - enrollment date (a Date object) The Student class provides a constructor that saves the student's name and enrollment date. Student(String name, Date whenEnrolled) The Student class provides accessors for the name and enrollment date. Make sure the class is immutable. Be careful with that Date field -- remember what to do when sharing mutable instance variables...

  • ( Object array + input) Write a Java program to meet the following requirements: 1. Define...

    ( Object array + input) Write a Java program to meet the following requirements: 1. Define a class called Student which contains: 1.1 data fields: a. An integer data field contains student id b. Two String data fields named firstname and lastname c. A String data field contains student’s email address 1.2 methods: a. A no-arg constructor that will create a default student object. b. A constructor that creates a student with the specified student id, firstname, lastname and email_address...

  • Write a program in Java according to the following specifications: The program reads a text file...

    Write a program in Java according to the following specifications: The program reads a text file with student records (first name, last name and grade on each line). Then it prompts the user to enter a command, executes the command and loops. The commands are the following: "print" - prints the student records (first name, last name, grade). "sortfirst" - sorts the student records by first name. "sortlast" - sorts the student records by last name. "sortgrade" - sorts the...

  • Implement a software program in C++ t stores and searches the Student records using double-hashing algorithm.  Double...

    Implement a software program in C++ t stores and searches the Student records using double-hashing algorithm.  Double hashing uses the idea of applying a second hash function to key when a collision occurs.   The software program will be based on the following requirements: Development Environment: If the software program is written in C++, its project must be created using Microsoft Visual Studio 2017. If the software program is written in Java, its project must be created using NetBeans v8.2. Algorithm: If...

  • In Java(using BlueJ) Purpose Purpose is to practice using file input and output, and array list...

    In Java(using BlueJ) Purpose Purpose is to practice using file input and output, and array list of objects. Also, this lab specification tells you only what to do, you now have more responsibility to design how to do it. Problem description You are given a text file called 'Students.txt' that contains information on many students. Your program reads the file, creating many Student objects, all of which will be stored into an array list of Student objects, in the Students...

  • please use java do what u can 1. Modify the Student class presented to you as...

    please use java do what u can 1. Modify the Student class presented to you as follows. Each student object should also contain the scores for three tests. Provide a constructor that sets all instance values based on parameter values. Overload the constructor such that each test score is assumed to be initially zero. Provide a method called set Test Score that accepts two parameters: the test number (1 through 3) and the score. Also provide a method called get...

  • Files given in this assignment (right-click on the file to download) Assignment7.cpp (need to complete) Student.h...

    Files given in this assignment (right-click on the file to download) Assignment7.cpp (need to complete) Student.h (Given. Just use it, don't change it!) Student.cpp (Partially filled, need to complete) 1. Assignment description In this assignment, you will write a simple class roster management system for ASU CSE100. Step #1: First, you will need to finish the design of class Student. See the following UML diagram for Student class, the relevant header file (class declaration) is given to you as Student.h,...

  • Please help, provide source code in c++(photos attached) develop a class called Student with the following protected...

    Please help, provide source code in c++(photos attached) develop a class called Student with the following protected data: name (string), id (string), units (int), gpa (double). Public functions include: default constructor, copy constructor, overloaded = operator, destructor, read() to read data into it, print() to print its data, get_name() which returns name and get_gpa() which returns the gpa. Derive a class called StuWorker (for student worker) from Student with the following added data: hours (int for hours assigned per week),...

  • Set-Up · Create a new project in your Eclipse workspace named: Lab13 · In the src...

    Set-Up · Create a new project in your Eclipse workspace named: Lab13 · In the src folder, create a package named: edu.ilstu · Import the following files from T:\it168\Labs\lab13. Note that the .txt file must be in the top level of your project, not inside your src folder. o Student.java o StudentList.java o students.txt Carefully examine the Student.java and StudentList.java files. You are going to complete the StudentList class (updating all necessary Javadoc comments), following the instruction in the code....

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT