Write a program to print the first half values in one line and the last half values in one line.
With a given tuple (1,2,3,4,5,6,7,8,9,10), write a program to print the first half values in one line and the last half values in one line.
Algorithm:
- Step1. Start
- Step2. declare tp and assign a value from 1 to 10.
- Step3. Assign the first 5 values of tp to tp1
- Step4. Assign the Last 5 value of tp to tp2
- Step5.Print tp1.
- Step6. Print tp2.
- Step6.End
Source Code:
tp=(1,2,3,4,5,6,7,8,9,10) tp1=tp[:5] tp2=tp[5:] print(tp1) print(tp2)
Output:
>>>
(1, 2, 3, 4, 5)
(6, 7, 8, 9, 10)
>>>
Recommended Posts:
- How to Create Forgot System Password with PHP & MySQL
- Datatables Editable Add Delete with Ajax, PHP & MySQL
- Download Login and Registration form in PHP & MySQL
- Export Data to Excel in Php Code
- Hospital Database Management System with PHP MySQL
Get Salesforce Answers