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.
- ECE210 Advocacy and Collaborations with Families Assignment: Supporting Young Children Through Grief and Family-Centered Partnerships
- ACC707 Accounting and Finance Assignment: Evaluating Investment Decisions, Budgeting Strategies, and Financial Performance Analysis
- NCO201 Learn to Learn, Learn for Life TMA-01: Developing Self-Directed Learning Through the Journey of Mastering Public Speaking
- PSS219 Public Safety and Security in Singapore Group-Based Assignment: Strengthening National Resilience Through Policy Responses from the 2025 Committee of Supply Debate
- MTH240 Engineering Mathematics I Assignment: Heat Transfer, Chemical Balancing, Circuit Analysis, Signal Processing, and Matrix Theory
- Engaging Youth with IBM Skills Build Assignment: Designing Innovative Strategies for Skill Development and Career Growth
- BUS368 Innovation Management and Digital Transformation Assignment: Managing Innovation in Foldable, Trifold, and Stretchable Display Technologies
- BUS366 Assignment: Process Improvement and Recruitment Optimization Using Lean Six Sigma Methodology
- HBC203 Statistics and Data Analysis for the Social and Behavioural Sciences TMA-01: A Comparative Analysis of Workplace Wellbeing Interventions and Their Impact on Employee Productivity
- BCAF003 Business Accounting Assignment: A Comprehensive Study on Bank Reconciliation, Cash Controls, Inventory Valuation, and Financial Analysis