rohidas

Hi I am Rohidas lande.I have teaching in C.D.jain college of commerce Shrirampur .I have Nine year in teaching Experience to teach various programming langauge,script languages,databases like Java,C,C++,php,python,html,css,javascript,mysql,oracle.

Python_Assignment1

Savitribai Phule Pune University T. Y. B. B. A. (C. A.) Semester-V (CBCS 2019 Pattern) CA-506: Lab Book Credits-03 Assignment 1: Introduction to Basic Python
Sr.NoAssignment name
Set-A
1
Write python script to calculate sum of digits of a given input number. Plz Click on Question to see Answer

n=int(input("Enter number:")) s=0 while n>0: d=int(n%10) s=s+d n=int(n/10) print("sum of digit=",s)


2
Write python script to check whether a input number is Armstrong number or not. Plz Click on Question to see Answer

n=int(input("Enter number:")) n1=n s=0 while n>0: d=int(n%10) s=s+d*d*d n=int(n/10) if n1==s: print("Number is armstrong") else: print("Number is not armstrong")


3
Write python script to check whether a input number is perfect number of not. Plz Click on Question to see Answer

n=int(input("Enter number:")) s=0 for i in range(1,n): if n%i==0: s=s+i if s==n: print("Number is perfect") else: print("Number is not perfect")


4
Write a program to calculate XY Plz Click on Question to see Answer

n1=int(input("Enter Base Element:")) n2=int(input("Enter Exponent Element:")) ans=n1**n2 print("Base to Power=",ans)


5
Write a program to check whether a input number is palindrome or not. Plz Click on Question to see Answer

n=int(input("Enter number:")) n1=n r=0 while n>0: d=int(n%10) r=r*10+d n=int(n/10) if n1==r: print("Number is palindrome") else: print("Number is not palindrome")


6
Write a program to calculate sum of first and last digit of a number. Plz Click on Question to see Answer

n=int(input("Enter number:")) id=n%10 while n>0: d=int(n%10) n=int(n/10) print("Sum of First & Last digit=",id+d)


Set-B
1
Write a program to accept a number and count number of even,odd, zero digits within that number. Plz Click on Question to see Answer

n=int(input("Enter number:")) even=0 odd=0 zero=0 while(n>0): d=int(n%10) n=int(n/10) if(d%2==0): even+=1 if(d%2!=0): odd+=1 if(d==0): zero+=1 print("Even digit count=",even) print("odd digit count=",odd) print("zero digit count=",zero)


2
Write a program to accept a binary number and convert it into decimal number. Plz Click on Question to see Answer

bno=input("ENter a Binary No:") dno=int(bno,2) print("Decimal of {p}={q}".format(p=bno,q=dno))


3
Write a program which accepts an integer value as command line and print “Ok” if value is between 1 to 50 (both inclusive) otherwise it prints ”Out of range”. Plz Click on Question to see Answer

n=int(input("Enter number:")) if n>=1 and n<=50: print("okk") else: print("out of range")


4
Write a program which accept an integer value ‘n’ and display all prime numbers till ‘n’. Plz Click on Question to see Answer

n=int(input("Enter Limit:")) print("All prime numbers:") for no in range(1,n): f=0 for i in range(2,no): if no%i==0: f=1 if f==0: print(no,end=" ")


5
Write python script to accept two numbers as range and display multiplication table of all numbers within that range. Plz Click on Question to see Answer

a=int(input("Enter NO 1:")) b=int(input("Enter NO 2:")) for i in range(1,11): for j in range(a,b+1): print(j*i,end=" ") print(" ")


Set-C
1
Write a python script to generate the following pattern upto n lines. 1 1 2 1 1 2 3 2 1 1 2 3 4 3 2 1 Plz Click on Question to see Answer

n=int(input("Enter Limit")) for i in range(1,n): for j in range(n,i,-1): print(" ",end=" ") for j in range(1,i+1): print(j,end=" ") for k in range(j-1,0,-1): print(k,end=" ") print(" ")


Post a Comment

0 Comments