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')

6 Comments

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

  1. [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)

    ReplyDelete
    Replies
    1. I Think this is code for duplicate values in List.

      Good 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)

      Delete
  2. Replies
    1. It will give Error.
      Because strings is immutable data type.

      Delete
  3. a=100
    b=20
    s=0
    while a>=b:
    if a%5==0:
    s+=a
    a-=1
    print(s)

    ReplyDelete
  4. #include
    int 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;
    }

    ReplyDelete

Post a Comment

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Previous Post Next Post