0% found this document useful (0 votes)
4 views1 page

Rotate Array Elements in Python

The document contains a Python script that prompts the user to input a number of elements to create an array. It then allows the user to specify how many elements to shift back in the array, performing the rotation by removing the first element and appending it to the end. Finally, it prints the array before and after the rotation.

Uploaded by

neeharika.sssvv
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views1 page

Rotate Array Elements in Python

The document contains a Python script that prompts the user to input a number of elements to create an array. It then allows the user to specify how many elements to shift back in the array, performing the rotation by removing the first element and appending it to the end. Finally, it prints the array before and after the rotation.

Uploaded by

neeharika.sssvv
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

n = int(input('Number of elements you want to enter in an array: '))

for i in range(n):
x = float(input('Enter the elements: '))
[Link](x)
print("Before rotation: ",lst)
s = int(input('Number of elements you want to shift back: '))
for i in range(s):
p = lst[0]
print(p)
[Link](p)
[Link](p)
print("After rotation: ",lst)

You might also like