University | Singapore University of Social Science (SUSS) |
Subject | FIN551: Python Programming |
(a) Write statements for the following tasks:
(i) Given a 2-digit whole number, n, display the message Valid if n contains the digit 1. For example, 10, 11 and 31 are valid but 33, 34 and 35 are not. Do not convert n into a string.
(ii) Given that string s has exactly 3 characters. Display the message Group A if characters in the first, middle and last positions are the same. For example, if s is ‘222’, display Group A. Display message Group B if the first and last characters are the same but the middle character is different. For example, if s is ‘232’, display Group B. Display message Group C if the first and last characters are not the same. For example, if s is ‘223’ or ‘213’, display Group C.
(iii) Given a list of numbers, nList such as [1, 3, 2]. If the sum of digits in the even position is even, display the message Sum of digits in even positions is even. Otherwise, display the message Sum of digits in even positions is odd. Do not use loop/repetition structure. Instead, use the slice operator and the built-in function sum.
(b) Given a string, s that contains a sequence of digits.
(i) Write a code segment that picks each digit in the string in reverse order, reduces each digit by 1 and displays the resulting number on separate lines. The code segment should produce the output for a given string ‘1204’: 3
-1
1
0
(ii) Write a code segment that prints the message True if the sum of each pair of adjacent digits does not exceed 12. Print the message False otherwise. For illustration, suppose the string s has 5 digits: d0d1d2d3d4. If d0 + d1, d1 + d2, d2 + d3, d3 + d4 do not exceed 12, the code segment prints True. Thus, for the string ‘48531’, the code segment prints the message False because the sum of pair of adjacent digits 85, or 8+5 exceeds 12.
Buy Custom Answer of This Assessment & Raise Your Grades
Are you searching for someone to do my assignment? then don't stress at Singapore Assignment Help we have proficient suss assignment experts who have an amazing capability to design outstanding solutions on FIN551: Python Programming Assignment. Our experts work 24*7 hours to provide all assignment answers before the deadline.
Looking for Plagiarism free Answers for your college/ university Assignments.
- BUS 304 Assignment: Strategic Analysis of Accounting Standards & Corporate Ethics
- RBP020L056 A Strategic Management Assignment Report: External & Internal Analysis with Strategic Options for Business Growth
- Capital Budgeting Assignment Report: PIONG Corporation Case Study on Risk & Investment Analysis
- BCAF003 Business Accounting Assignment : Temasek Polytechnic Case Study on Transactions, Equity & Trial Balance
- 304SE Energy Systems Assignment: Boiler Efficiency & 3-Bus Power Flow Case Study with Carbon Emission Analysis
- SM9532 International Expansion Strategy Assignment Report: CAGE, PND & AAA Analysis for Global Market Entry
- PSB6023CL Strategy and International Business Simulation Assignment Report: Automotive Case Study on Strategic Decision-Making and Performance Review
- ESG in Maritime Industry Assignment : Literature Review on Environmental, Social and Governance Practices
- CVE2332 Seepage and Flownet Analysis Assignment : Singapore River Cofferdam Case Study for Cost-Effective Sheet Pile Design
- DSWSH MC2 Electronic Security Assignment: Protection in Depth Plan for American International School (AIS) Singapore