This commit is contained in:
2024-09-30 18:17:21 +02:00
parent 483d40da91
commit 9a1615c1ea
14 changed files with 107 additions and 8 deletions

8
WS24_25/PyCharm/pythonProject/.idea/.gitignore generated vendored Normal file
View File

@@ -0,0 +1,8 @@
# Default ignored files
/shelf/
/workspace.xml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml

View File

@@ -0,0 +1,6 @@
<component name="InspectionProjectProfileManager">
<settings>
<option name="USE_PROJECT_PROFILE" value="false" />
<version value="1.0" />
</settings>
</component>

View File

@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Black">
<option name="sdkName" value="Python 3.12 (pythonProject)" />
</component>
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.11 (pythonProject)" project-jdk-type="Python SDK" />
</project>

View File

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/pythonProject.iml" filepath="$PROJECT_DIR$/.idea/pythonProject.iml" />
</modules>
</component>
</project>

View File

@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/.venv" />
<excludeFolder url="file://$MODULE_DIR$/venv" />
</content>
<orderEntry type="jdk" jdkName="Python 3.11 (pythonProject)" jdkType="Python SDK" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$/../../.." vcs="Git" />
</component>
</project>

View File

@@ -0,0 +1,51 @@
# def fac(x,y=2):
# return x**y
# list = [1,2,3]
# list2 =[]
# for i in range(len(list)):
# list[i] = fac(list[i])
# print (list)
class Lecture:
def __init__(self, title):
"""
Initializes a new Lecture instance with a title and an empty list of students.
:param title: Title of the lecture
"""
self.title = title
self.students = []
def add_student(self, student_name):
"""
Adds a student to the lecture.
:param student_name: Name of the student to be added
"""
if student_name not in self.students:
self.students.append(student_name)
print(f"{student_name} has been added to the lecture '{self.title}'.")
else:
print(f"{student_name} is already enrolled in the lecture '{self.title}'.")
def number_of_students(self):
"""
Returns the number of students enrolled in the lecture.
:return: The count of students
"""
return len(self.students)
# Example usage
# Create a new lecture
python_lecture = Lecture("Introduction to Python")
# Add students
python_lecture.add_student("Alice")
python_lecture.add_student("Bob")
python_lecture.add_student("Alice") # Attempt to add Alice again
# Get the number of students
print(f"Number of students enrolled in '{python_lecture.title}': {python_lecture.number_of_students()}")