⚠
️ DEPRECATED GITLAB INSTANCE
⚠
️ This GitLab is now read-only for reference. Please use
https://gitlab.iauro.co
for all new work.
Migration completed on September 17, 2025
Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
Arti Dongare
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Packages
Packages
Container Registry
Analytics
CI / CD Analytics
Repository Analytics
Value Stream Analytics
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Arti Dongare
Arti Dongare
Commits
2e205695
Commit
2e205695
authored
Jun 25, 2025
by
MotiramShinde
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1st python assignment
parent
e4d44b3c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
149 additions
and
0 deletions
+149
-0
1_Assignment_Python_Fundamentals/calculator.py
1_Assignment_Python_Fundamentals/calculator.py
+28
-0
1_Assignment_Python_Fundamentals/file.py
1_Assignment_Python_Fundamentals/file.py
+47
-0
1_Assignment_Python_Fundamentals/student.py
1_Assignment_Python_Fundamentals/student.py
+74
-0
No files found.
1_Assignment_Python_Fundamentals/calculator.py
0 → 100644
View file @
2e205695
def
calculator
():
while
True
:
try
:
num1
=
float
(
input
(
"Enter first number: "
))
op
=
input
(
"Enter operator (+, -, *, /): "
)
num2
=
float
(
input
(
"Enter second number: "
))
if
op
==
'+'
:
result
=
num1
+
num2
elif
op
==
'-'
:
result
=
num1
-
num2
elif
op
==
'*'
:
result
=
num1
*
num2
elif
op
==
'/'
:
if
num2
==
0
:
print
(
"Cannot divide by zero."
)
continue
result
=
num1
/
num2
else
:
print
(
"Invalid operator."
)
print
(
f
"Result: {result}"
)
break
except
ValueError
:
print
(
"Please enter valid numbers."
)
calculator
()
1_Assignment_Python_Fundamentals/file.py
0 → 100644
View file @
2e205695
import
argparse
import
os
import
json
import
csv
def
parse_file
(
path
,
file_type
):
if
not
os
.
path
.
exists
(
path
):
print
(
"File not exist."
)
return
try
:
if
file_type
==
"text"
:
with
open
(
path
,
"r"
)
as
f
:
print
(
f
.
read
())
elif
file_type
==
"lines"
:
with
open
(
path
,
"r"
)
as
f
:
for
i
,
line
in
enumerate
(
f
,
1
):
print
(
f
"{i}: {line.strip()}"
)
elif
file_type
==
"csv"
:
with
open
(
path
,
newline
=
''
)
as
f
:
reader
=
csv
.
reader
(
f
)
for
row
in
reader
:
print
(
row
)
elif
file_type
==
"json"
:
with
open
(
path
,
"r"
)
as
f
:
data
=
json
.
load
(
f
)
print
(
json
.
dumps
(
data
,
indent
=
2
))
else
:
print
(
"Unsupported file type."
)
except
Exception
as
e
:
print
(
"Error:"
,
e
)
def
main
():
parser
=
argparse
.
ArgumentParser
(
description
=
"File Parser CLI"
)
parser
.
add_argument
(
"filepath"
,
help
=
"Path to file"
)
parser
.
add_argument
(
"--type"
,
default
=
"text"
,
choices
=
[
"text"
,
"lines"
,
"csv"
,
"json"
])
args
=
parser
.
parse_args
()
parse_file
(
args
.
filepath
,
args
.
type
)
if
__name__
==
"__main__"
:
main
()
1_Assignment_Python_Fundamentals/student.py
0 → 100644
View file @
2e205695
class
Student
:
def
__init__
(
self
,
roll_no
,
name
,
age
):
self
.
roll_no
=
roll_no
self
.
name
=
name
self
.
age
=
age
def
display
(
self
):
print
(
f
"Roll No: {self.roll_no}, Name: {self.name}, Age: {self.age}"
)
students
=
[]
def
add_student
():
roll_no
=
input
(
"Enter roll number: "
)
name
=
input
(
"Enter name: "
)
age
=
input
(
"Enter age: "
)
student
=
Student
(
roll_no
,
name
,
age
)
students
.
append
(
student
)
print
(
"Student added successfully!"
)
def
view_students
():
if
not
students
:
print
(
"No students to display."
)
else
:
print
(
"Student List:"
)
for
s
in
students
:
s
.
display
()
def
search_student
():
roll_no
=
input
(
"Enter roll number to search: "
)
found
=
False
for
s
in
students
:
if
s
.
roll_no
==
roll_no
:
print
(
"Student found:"
)
s
.
display
()
found
=
True
break
if
not
found
:
print
(
"Student not found."
)
def
delete_student
():
roll_no
=
input
(
"Enter roll number to delete: "
)
for
s
in
students
:
if
s
.
roll_no
==
roll_no
:
students
.
remove
(
s
)
print
(
"Student deleted."
)
return
print
(
"Student not found."
)
def
main
():
while
True
:
print
(
"
\n
=== Student Management System ==="
)
print
(
"1. Add Student"
)
print
(
"2. View All Students"
)
print
(
"3. Search Student"
)
print
(
"4. Delete Student"
)
print
(
"5. Exit"
)
choice
=
input
(
"Enter your choice (1-5): "
)
if
choice
==
"1"
:
add_student
()
elif
choice
==
"2"
:
view_students
()
elif
choice
==
"3"
:
search_student
()
elif
choice
==
"4"
:
delete_student
()
elif
choice
==
"5"
:
break
else
:
print
(
"Invalid choice.try again"
)
main
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment