Q. Find error in the following code (if any) and correct it by rewriting the code and underline the corrections:
code = input ("Enter season code: ")
if code = w:
print "winter season"
elif code == r:
PRINT "rainy season"
else:
Print 'summer season'
Answer :-
code = input ("Enter season code: ")
if code == 'w':
print ("winter season")
elif code == 'r':
print ("rainy season")
else:
print ('summer season')
[10,20,30,20,10,50,60,40,80,50,40]
ReplyDeletedup_items = []
uniq_items = []
for x in a:
if x not in dup_items:
uniq_items.append(x)
dup_items.append(x)
print(dup_items)
I Think this is code for duplicate values in List.
DeleteGood Idea : )
a = [10,20,30,20,10,50,60,40,80,50,40]
dup_items = []
uniq_items = []
for x in a:
if x not in dup_items:
uniq_items.append(x)
dup_items.append(x)
print(dup_items)
S="Save tiger"
ReplyDeleteS[5]='T'
It will give Error.
DeleteBecause strings is immutable data type.
a=100
ReplyDeleteb=20
s=0
while a>=b:
if a%5==0:
s+=a
a-=1
print(s)
#include
ReplyDeleteint main()
{
int arr[30];
int i,n;
printf("enter no.of array element");
scanf("%d",&n);
printf("enter the array element");
for(i=0;i<n;i++)
scanf("%d",&arr[i]);
int visited[n];
for(i=0;i<n;i++)
{
if(visited[i]==0){
int count=1;
for(int j=i+1;j<n;j++)
{
if (arr[i]==arr[i])
{
count ++;
visited[j]=1;
}
}
printf("%d occur %d times \n",arr[i],count);
}
}
return 0;
}
Post a Comment
You can help us by Clicking on ads. ^_^
Please do not send spam comment : )