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

Pramod Kumar Yadav is from Janakpur Dham, Nepal. He was born on December 23, 1994, and has one elder brother and two elder sisters. He completed his education at various schools and colleges in Nepal and completed a degree in Computer Science Engineering from MITS in Andhra Pradesh, India. Pramod has worked as the owner of RC Educational Foundation Pvt Ltd, a teacher, and an Educational Consultant, and is currently working as an Engineer and Digital Marketer.



Leave a Comment