Program with function and purpose that we personally worked on with my team test, this is our part!
# Program with Output
print("Program with Output")print("Hello, world")
Program with Output
Hello, world
# Program with Input and Output
print("\nProgram with Input and Output")name=input("Enter your name: ")print("Hello, "+name+"!")
Program with Input and Output
Enter your name: will
Hello, will!
# Program with a List
print("\nProgram with a List")fruits=["apple","banana","cherry"]forfruitinfruits:print(fruit)
Program with a List
apple
banana
cherry
# Program with a Dictionary
print("\nProgram with a Dictionary")student={"name":"Will","age":25,"grade":"A"}print("Student Information:")forkey,valueinstudent.items():print(key+": "+str(value))
Program with a Dictionary
Student Information:
name: Will
age: 25
grade: A
# Program with Iteration (stop here will), one based numbering
print("\nProgram with Iteration")foriinrange(1,6):print("Number:",i)
Program with Iteration
Number: 1
Number: 2
Number: 3
Number: 4
Number: 5
# Program with a Function to perform mathematical and/or statistical calculations
print("\nProgram with a Function for Calculation")defcalculate_average(numbers):total=sum(numbers)average=total/len(numbers)returnaverage
Program with a Function for Calculation
# Program with a Function to perform mathematical and/or statistical calculations
print("\nProgram with a Function for Calculation")defcalculate_average(numbers):total=sum(numbers)average=total/len(numbers)returnaveragedata=[10,15,20,25,30]avg=calculate_average(data)print("Average:",avg)
Program with a Function for Calculation
Average: 20.0
# Program with a Selection/Condition
print("\nProgram with Selection/Condition")num=int(input("Enter a number: "))ifnum%2==0:print(num,"is even.")else:print(num,"is odd.")
Program with Selection/Condition
17 is odd.
# Program with Purpose
print("\nProgram with Purpose")deffind_factorial(n):ifn==0:return1else:returnn*find_factorial(n-1)number=int(input("Enter a number to find its factorial: "))factorial=find_factorial(number)print("Factorial of",number,"is",factorial)
Program with Purpose
Enter a number to find its factorial: 18
Factorial of 18 is 6402373705728000