Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

python programs Write a program which adds two fraction using functions as described below: getFrac: Asks the user to enter the numerator and the denominator

image text in transcribedimage text in transcribedimage text in transcribedpython programs

Write a program which adds two fraction using functions as described below: getFrac: Asks the user to enter the numerator and the denominator of the fraction and returns these integers to the calling program. addFrac: Receives numerators and denominators of two fractions as arguments and returns the numerator and denominator of the sum of the two fractions. o prnFrac: Receives the numerator and the denominator of a fraction and prints numerator/denominator to the screen. main: Asks the user to enter two fractions using the getFrac function, adds these two fractions using the addFrac function, then prints the sum to the screen using the prnFrac function. The program output should be displayed exactly as shown in the example outputs below depending on what user enters. Do not simplify the fraction. (Chry Enter numerator: 1 Enter numerator: 2 Enter denominator: 3 Enter denominator: 3 Enter numerator: 1 Enter numerator: 5 Enter denominator: 2 Enter denominator: 6 1/3+1/2 = 5/6 2/3 + 5/6 = 27/18 . Write a program to find if the user wins a prize in a special lottery (piyango). The lottery ticket numbers are 4 digits starting from 1000 ending with 9999. The winning number is in a file called winNum.txt (Just one line, with a 4-digit number). The program reads the winning number from winNum.txt file, asks the user to enter his/her 4-digit ticket number, checks if number is valid (1000-9999), then displays the prize: 1000TL if all 4 digits match or 10TL if only the last digit matches. The program output should be displayed exactly as shown in the example outputs below depending on what user enters. Example outputs, assuming winNum.txt file contains 7548. (C1) Enter ticket number: 123 Enter ticket number: 7548 Enter ticket number: 9348 The number should be 1000 - 9999 You won 1000TL You won 10TL Enter ticket number: 1223 Better luck next time Write a program that starts with an empty list, adds names to the list entered by the user until the user enters done. If the name is already in the list, it is not duplicated (not added to the list When the user is done adding names, the program then sorts the list and prints it to the screen The program output should be displayed exactly as shown in the example outputs below depending on what user enters. Enter 'done' to exit the program Enter a name: Hasan Name added to the list. Enter a name: Ayse Name added to the list. Enter a name: Hasan Name already in list. Enter a name: Nuri Name added to the list. Enter a name: done ['Ayse', 'Hasan', 'Nuri']

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases Illuminated

Authors: Catherine Ricardo

2nd Edition

1449606008, 978-1449606008

More Books

Students also viewed these Databases questions