- 9th Jul 2024
- 10:02 am
In this project you choose a problem to solve: To solve Create an entry level python code with a minimum of 3 defined functions, that satisfy the criteria’s listed below.
Criteria: The Problem - Your program must be written for a specific purpose - it must be intended to solve a problem. It must be accompanied by a short statement explaining what problem it solves and how - include this as a comment at the start of the program, immediately after your file comment. If you aren't sure whether your problem is good enough, feel free to ask me.
Criteria: Non-Triviality - Your program must be non-trivial; you need to pick a problem that requires the program to do several things to solve it. A program that is less than about fifty lines – not counting comments and blank lines! – is probably trivial for these purposes. A program that only follows one possible path with minor branches is probably also trivial – your program needs to make real decisions.
Criteria: The Checklist
Your program must do all the following:
- Accept input from the terminal
- Produce output to the terminal
- Use both string and numeric variables meaningfully
- Use conditional statements to make decisions
- Use loops to deal with data iteratively
- Use lists or dictionaries to manage data
- Optionally, use turtle graphics
Mechanics
Follow all of our coding guidelines as documented. Your program must run without errors or warnings as long as it’s given valid input. You don’t need to check against invalid input – we won’t intentionally try to break your program.
Create A Non-Trivial Python Program To Solve A Problem - Get Assignment Solution
Please note that this is a sample Python Program assignment solved by our Python Experts. These solutions are intended to be used for research and reference purposes only. If you can learn any concepts by going through the reports and code, then our Python Tutors would be very happy.
- To download the complete solution along with Code, Report and screenshots - Please visit our Python Assignment Sample Solution page
- Reach out to our Python Tutors to get online tutoring related to this assignment and get your doubts cleared
- You can check the partial solution for this assignment in this blog below
Free Assignment Solution - Create A Non-Trivial Python Program To Solve A Problem
'''
This problem is used to check whether 10 is an even number or an odd number.
If it is an even number then it will print '10 is even', otherwise it will print '10 is odd'
'''
def problem():
number = 10
if number % 2 == 0:
print(number," is even")
else:
print(number," is odd")
'''
In this problem we are going to take a number input from the user, and reverse it.
After reversing if it is the same number(as input) then we print the sum of it's digit otherwise we print the multiplication of it's digit.
'''
def non_triviality():
n = int(input("Enter the number : "))#get user input
rev = 0
temp = n
while(temp>0):#repeat until temp does no become less than 0
rev = (rev*10) + (temp%10)#get the last digit of number
temp = temp//10
if (rev == n):#if it is palindrome number
temp = n
sum = 0
while(temp > 0):#extract each digit and add it
sum += temp % 10
temp = temp//10
print("Sum of digit of ",n," is ",sum)
else:
temp = n
mul = 1
while(temp > 0):#extract each digit and multiply it
mul *= temp % 10
temp = temp//10
print("Multiplication of digit of ",n," is ",mul)
'''
Create a menu diven program in which user can add student to the list,
view particular student in the list, and view all the student in the list
'''
def checklist():
student_list =[]#create a list to store student data
while(True):
#print menu to the user and get it's choice
print("1. Add a student")
print("2. View a student")
print("3. View all student")
print("4. Exit")
choice = input("Enter your choice: ")
if choice == "1":#if user choose to add student to the list
while(True):#repeat until user does not enter valid id
id = input("Enter student Id: ")
flag = True
for i in student_list:#iterate over the student list and check wheter id already present or not
if id in i:#if id is present
flag = False
print("Id Already present, Choose again")
break
if flag == True:#if id is not present
break
name = input("Enter Student Name: ")
number = input("Enter Student Phone Number: ")
student_list.append([id,name,number])#add student to the list
print("Student Added")
elif choice == "2":
flag = False
id = input("Enter student id whose details you want to see : ")#get student id whose details you want to see
for i in student_list:#itereate over the list and see if there is any student present with given id
if id in i:#if student present print it's detail
print("Id : " + i[0])
print("Name : " + i[1])
print("Number : " + i[2])
flag = True
if flag ==False:#if student not found
print("No Student found with given id")
elif choice == "3":#if user choose to view all student data
if len(student_list) == 0:#if there is not student present in the list
print("No student present in the list")
else:
for i in student_list:#iterate over the list and print it details
print("Id : " + i[0])
print("Name : " + i[1])
print("Number : " + i[2])
print()
elif choice == "4":#if user choose to exit the program
break
else:
print("Wrong Choice!!! Try again...")
print()
problem()#call first funciton
non_triviality()#call the second function
checklist()#call the third function
Get the best Create A Non-Trivial Python Program To Solve A Problem assignment help and tutoring services from our experts now!
About The Author - Alex Bennett
Alex Bennett is a seasoned software engineer with a focus on developing robust and efficient Python applications. With a background in problem-solving and algorithm design, Alex excels at creating entry-level Python programs that address real-world challenges. His expertise lies in writing non-trivial code that incorporates meaningful use of strings and numeric variables, conditional statements, loops, and data structures such as lists and dictionaries.