Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions Students/Aakriti/Python/args.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# 4. Function with *args
# Write a function student_marks multiple subjects that returns:

# # total marks
# # average marks
def student_marks(*args):
print(args)
marks=sum(args)
average_marks= marks/len(args)
return marks, average_marks


total, average=student_marks(50,50,50,50)
print("Total marks=",total)
print("Average=", average)


# Function with **kwargs
# Write a function student(**details) that prints all key-value pairs.

def student(**details):
print(details)
for key, value in details.items():
print(f"{key}:{value}")

student(
Name ="Aakriti",
age=19,
club='Software'

)
13 changes: 13 additions & 0 deletions Students/Aakriti/Python/circle.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#Write a function circle(radius) that returns:
# area
# circumference
import math
def circle(radius):
area=math.pi*radius**2
circum=2*math.pi*radius

return area,circum

AreaOfCircle, PeriOfCircle=circle(24)
print(f"The area of given circle is : {round(AreaOfCircle,2)}")
print(f" The circumference of circle is : {round(PeriOfCircle,2)}")
8 changes: 8 additions & 0 deletions Students/Aakriti/Python/greet.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Create a function that greets users, but if no name is provided, it greets "Guest".

def greeting(name="Guest"):
name=name.strip() or "Guest"
print("Hello, " + name + "! Welcome to the Python programming course.")

user_name=input("Enter your name: ")
greeting(user_name)
12 changes: 12 additions & 0 deletions Students/Aakriti/Python/largest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Create a function that finds the largest number using *args

def largest(*args):
lar=0
for x in args:
if x >lar:
lar=x
print(f"The largest number is :{lar}")



largest(1,2,30,400,5,6,7)
13 changes: 13 additions & 0 deletions Students/Aakriti/Python/product.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#Create a function that accepts product details using **kwargs name ,price and quantity and prints them in a formatted way.

def product(**details):
for key,value in details.items():

# print(f"The Detils of your product are {key}: {value}")
print(f"{key}: {value}")
print("The details of your products are below :")
product(
Name="Cookies",
Price=250,
Quantity=3
)
6 changes: 6 additions & 0 deletions Students/Aakriti/Python/square.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# hw:Create a function square(num) that returns the square of a number.

def square(num):
return num**2

print(square(4))
15 changes: 15 additions & 0 deletions Students/Aakriti/Python/studentmarks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# 2.Write a function student_marks(math, science) that returns:

# total marks
# average marks

def student_marks(math,science):
total_marks=math+science
average_marks=total_marks/2
return total_marks,average_marks

math_marks=int(input("Enter marks for Math: "))
science_marks=int(input("Enter marks for Science: "))
total, average = student_marks(math_marks,science_marks)
print(f"Total marks: {total}")
print(f"Average marks: {average}")
Loading