Write a program to print the first half values in one line and the last half values in one line.

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:

Get Salesforce Answers

Leave a Reply

%d bloggers like this: