COM1001 – COMPUTER ENGINEERING DEPARTMENT (Solution)

$ 29.99
Category:

Description

Computer Programming 1
LAB2 Quiz
Assoc. Prof. Dr. Hacer YALIM KELEŞ

Write a Python program which takes a set of inputs that contain strings, positive integers and 9loating point numbers in mixed order, prints the sum of the integers, sum of the 9loats and concatenation of the strings in separate lines in this order.
Speci&ication details:
– There is no speci9ic order in the given literals.
Constraints:
– You are not allowed to use any string class func3ons, such as str.isnumeric() or str.isdigit() etc. You need to iden3fy the type of the items by inspec3ng individual characters in it (see the Hint below)
– Floa3ng point numbers will only be provided using dot (.) conven3on; and dot (.) will only appear in float numbers, i.e. strings will not contain any dots.
Hints:
You will read the input using:
inputs = map(str, input().split())
ADer reading, inputs variable is bound to a sequence (list) of strings. You can iterate over the individual items using in operator in a for loop, i.e. similar to itera3ng over a range of values using the range func3on; e.g. for item in inputs:.
You are expected to implement your own solu3ons to determine if a par3cular string contains an integer or a float number using itera3ons over the characters in the string. As we have seen, you can iterate over individual characters of a string, str, using in operator; e.g. for chr in str:
I/O Format:
Input format: [[posi3ve integer]*[Space][float]*[Space][string]*[Space]]*
Output
format:<sum_of_ints_if_given>[Newline]<sum_of_floats_if_given>[Newline]<concat_of_strings_if_gi ven>[Newline]
Note that:
1- Sample input and output files are provided.
2- [x]* means, zero or more elements of x
Submission:
1- Name your Python source file as <student_id>.py; replace <student_id> using your student id number.
2- Upload your python file using the interface provided in e-kampüs course page.

Reviews

There are no reviews yet.

Be the first to review “COM1001 – COMPUTER ENGINEERING DEPARTMENT (Solution)”

Your email address will not be published. Required fields are marked *