Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 1fa3ff1

Browse files
Create solution.hide.py
1 parent d380b93 commit 1fa3ff1

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Your code here
2+
class Student:
3+
def __init__(self, name, age, grade): # These are its attributes
4+
self.name = name
5+
self.age = age
6+
self.grade = grade
7+
8+
def introduce(self): # This is a method
9+
return f"Hello! I am {self.name}, I am {self.age} years old, and my current grade is {self.grade}."
10+
11+
def study(self, hours): # This is another method
12+
self.grade += hours * 0.5
13+
return f"After studying for {hours} hours, {self.name}'s new grade is {self.grade}."
14+
15+
student1 = Student("Ana", 20, 80)
16+
17+
print(student1.introduce())
18+
print(student1.study(3))

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /