Professional Documents
Culture Documents
Code:
name=input("Enter your name: ").strip()
sur_name=input("Enter your surname: ").strip()
print(name+' '+sur_name)
Output:
Code:
num=int(input("Enter number here: "))
sqr=int(num ** 0.5)
print("Your answer:",sqr)
Output:
Q3) Write a python program to take any word from the user as
input and show how many characters it contains.
Code:
enter_string=input().strip()
count=0
for i in range (0,len(enter_string)):
if(enter_string[i]!=' '):
count+=1
Output:
Q4) Write a python program to find out the ASCII value of any
given character.
Code:
mychar=input("Enter any character:").strip()
ascii_myhar=ord(mychar)
print(ascii_myhar)
Output:
Q5) Write a python program to open Google homepage.(Use
'import web browser')
Code:
import webbrowser
webbrowser.open('https://www.google.com')
Output:
Opens google homepage
Code:
Output:
Output:
Q8)Write a python program to find out the HCF and LCM of two
numbers.
Code:
a=int(input())
b=int(input())
if(b<a):
a,b=b,a
if a==0:
print("hcf",b)
print("LCM",a)
else:
l=a
r=b
while(a!=0):
c=a
a=b%a
b=c
print("HCF of(",l,r,") is ", b)
lcm=(l*r)//b
print("LCM of(",l,r,") is ",lcm)
Output:
Q9) Write a python program to check a given number is
Armstrong number or not.
Code:
Output:
Code:
import math as m
def circle(rad):
ar = (m.pi * (rad ** 2))
cir = (2 * m.pi * rad)
print("area of the circle is:","%.2f"%ar," and cicumference of
circle is:","%.2f"%cir)
rad=int(input("Enter radius:"))
circle(rad)
Output: