0% found this document useful (0 votes)
5 views3 pages

CS Parcticle Code.

Uploaded by

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

CS Parcticle Code.

Uploaded by

mohitayadav77
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Q.1 Write a program to find the largest number in a list .

x=[1,3,2,6,5,67,68]
for i in range(0,len(x)):
for j in range(len(x)-i-1):
if x[j]>x[j+1]:
x[j],x[j+1]=x[j+1],x[j]
print(x[-1])

Q.2 Write a program to swap elements at the even location with


elements odd location.
x=[11,34,56,87,98,23]
for i in range(0,len(x)-1,2):
x[i],x[i+1]=x[i+1],x[i]
print(x)

Q.3 Input a list of elements and search a particular element.


y=int(input('Enter element to find if it is in string:'))
x=[34,56,78,98,21,65]
if y in x:
print('Element found')
else:
print('Element not found')

Sorry Q.4 is not in my expertiese.


Q.5 Write a program to find LCM or HCF of any two integer.
x=int(input('Enter number to find if it is prime or not;'))
for i in range(2,x):
if x==1:
print('Number is 1, neighter prime and nor composite')
elif x%i==0:
print('Number is not prime')
break
else:
print('Number is prime')
break

Q.6 write a program to check the number if palindrome or not.


x=input('Enter the value to check if palindrame or not:')
y=x[::-1]
if x==y:
print('Entered value is palindrome')
else:
print('Value is not palindrome')
Q.7 Write a program to arrange string in ascending order by any
sorting method.
x=[8,7,6,5,4,3,2,1]
for i in range(0,len(x)):
for j in range(len(x)-i-1):
if x[j]>x[j+1]:
x[j],x[j+1]=x[j+1],x[j]
print(x)

Q.8 Write a program to check if given number is negative, positive


or zero.
x=int(input('Enter value to check if it is negetive, positive or zero:'))
if x==0:
print('Entered value is zero.')
elif x>0:
print('Value is positive.')
else:
print('value is negetive.')

You might also like