livepython.net

182. Python Program to Make a Student Class with __init__

Easy__init__

Overview

Let __init__ give every new object its attributes, instead of adding them by hand.

Problem Statement

Define a class Student with an __init__ method that stores two attributes: name and marks. Read a student's name and marks (a whole number), create a Student from them, and print three lines from the object's attributes. The result is Pass for marks of 40 or more, and Fail otherwise.

Use input() with no prompt text: the tests type the input for you, and a prompt would end up in your output.

Input

Two lines: the name, then the marks. Example:

Sunny
82

Output

The output for that example:

Name: Sunny
Marks: 82
Result: Pass

The tests try 4 different inputs.

Learn this firstChapter 20 · Python __init__ Method, self and Attributes
solution.py
# write your code here

EXPECTED OUTPUT

1Name: Sunny
2Marks: 82
3Result: Pass

YOUR OUTPUT

Press Run to see your output here. Lines are compared with the expected output.