Breaking

Wednesday, October 20, 2021

python basic programs for beigners

 


#Toady what i gonna do is solve all the questions i write in this page.

#Q1. Write a program to print "harry" five times?
'''
a = 0
while a<5:
print("Harry")
a+=1

'''
#OR

'''
for i in range(5):
if i < 5:
print("Harry")

'''

#Q2. Write a program to print the content of a list using while loop.
'''
l=[1,2,3,4,5,6,7,89]
a = 0
while a<len(l):
print(l[a])
a = a+1

'''


#Q3. Write a program to printy infinite loop by while.

'''a = 0
while a==a:
print(a)
a = a+1
'''
#OR
'''
a = 0
for i in a:
print(i)
a = a+1

'''

#Q4. Print the table of any number using while loop.
'''
n = int(input("Enter the number = "))
a = 1
while a<11:
print(n*a)
a+=1

'''

#Q5. Print the table of any numbner using the for loop.
'''
n = int(input("Enter the number = "))
for i in range(1,11):
print(i*n)
'''

#Q6. Write a progam to find trhe the number is prime or not.
'''
n = int(input("Ente rthe numbner = "))
for i in range(2,n):
if n%i==0:
print("it is not prime")
break
else:
print("it is prime")
'''

#Q7. Write a program to find the sum of 1st n natural number by using for loop.
'''
n = int(input("Enter the number = "))
a = 0
for i in range(1,n+1):
a = i+a
print(a)

'''
#Q8. Write a program to find factorial of given number using for loop.
'''
n = int(input("Enter the number = "))
a = 1
for i in range(1,n+1):
a = i*a
print(a)

'''

#Q9. Write a following to print the following pattern.
'''
*
**
***
'''

'''

for i in range(4):
print(i*"*")

'''

#Q10. Write a program to find the greatest number entered by user.
'''
n1 = int(input("Enter the number = "))
n2 = int(input("Enter the number = "))
n3 = int(input("Enter the number = "))

if n1>n2 and n1>n3:
print("This Number Is Greater",n1)
elif n2>n3 and n2>n1:
print("This Number Is Greater",n2)
else:
print("This Number Is Greater",n3)

'''

#Q11. Write a program to find out wheather a student is pass or fail is require
# totl 40% and at least 33% in
# each subject to pass input from user 5 subject are there.

'''
n1 = int(input("Enter The NUmber = "))
n2 = int(input("Enter The NUmber = "))
n3 = int(input("Enter The NUmber = "))
n4 = int(input("Enter The NUmber = "))
n5 = int(input("Enter The NUmber = "))

sum = n1+n2+n3+n4+n5
num = (sum/500)*100

if num<33:
print("fail")
else:
print("pass")

'''

#Q12. A span comment is defined as text contining following keywords.

'''
txt = input("Enter The Statement = \n")
if "win cash" in txt:
print("This Is a Spam")
elif "lucky" in txt:
print("This Is a Spam")
elif "get money" in txt:
print("This Is a Spam")
else:
print("this is not span your are safe")
'''

#Q13. Write a program to find wheather the given user contain less than 10 characters.
'''
t = input("Enter The NUmber = ")
if len(t)== 10:
print("this number has 10 digits ",t)
else:
print("You made a error")
'''

#Q14. Write down the program that find the name is in given list or not.
'''
l = ["aryan",'diya']
n = input("Enetr the name = ")
if n in l:
print("yes it is presnet in the list",n)
else:
print("no it is not in list")

'''

#Q15. Write a program to calculate the grade of student from his marks.
'''
num = int(input("Enetr The NUmber = "))
if num>=90:
print("your are first")
elif num>=80:
print("You are second")
elif num>=70:
print("your are third")
elif num>=60:
print("your get 1st division")
elif num>=50:
print("you get 2nd division")
elif num>=40:
print("you will Pass")
else:
print("you will Fail")

'''

#Q16. Write a program to find that wheather a post is talk about harry or not.
'''
t = input("Enter the post = ")
if "Harry" in t:
print("Ths post is talk about harry")
elif "harry" in t:
print("Ths post is talk about harry")
elif "hArry" in t:
print("Ths post is talk about harry")
elif "haRRY" in t:
print("Ths post is talk about harry")
elif "HARRY" in t:
print("Ths post is talk about harry")
else:
print("Ths post is not talk about harry")

'''

#Q17. Wirte a program to find out the remainder when divided by 2.
'''
n = int(input("Enter The Number = "))
d = n/2
print("the remainder is = ",d)

'''

#Q18. Check the type of varibale assinged to the varible using the input fuction.
'''
a = int(input("Enter the variable = "))
b = str(input("Enter the variable = "))
c = float(input("Enter the variable = "))
print(type(a))
print(type(b))
print(type(c))

'''

#Q19. Write a program to find the average of two numbers entered by the users.
'''
num1 = int(input("Enter The Number = "))
num2 = int(input("Enter The Number = "))
average = num1+num2/2
print(average)

'''

#Q20. Write a program to find the square entered by user.
'''
num = int(input("Enter The Number = "))
sq = num**2
print(sq)

'''

#Q21. Write a program to entered name of folloed by good morning using input function.
'''
name = input("Enter The Name = ")
print("Good Morning",name)

'''
#Q22. Write a porgram to enter fill letter template name and date.
'''
name = input("Enter The Name = ")
date = input("Enter The Name = ")
l =
To
The Pricncipal
N.C.JAIN.MEMORIAL.PUBLIC.SCHOOL
CHIRGAON (JHANSI) -284301
Date:-<|Date|>
Dear Sir
repectfully i beg to say that i am suffering from a
viral fever so i requested you to give me a leave for 2 days

Thankyou
Your Obediently
<|Name|>



l = l.replace("<|Name|>",name)
l = l.replace("<|Date|>",date)
print(l)

'''

#Q22. Write a program to store seven fruits in a list entered by user.
'''
f1 = input("enter the fruit name = ")
f2 = input("enter the fruit name = ")
f3 = input("enter the fruit name = ")
f4 = input("enter the fruit name = ")
f5 = input("enter the fruit name = ")
f6 = input("enter the fruit name = ")

l = [f1,f2,f3,f4,f5,f6]
print(l)

'''
#Q23. Write a program to accept the number of 6 student and display in sorted manner.
'''
s1 = input("Enter the number of 1 = ")
s2 = input("Enter the number of 2 = ")
s3 = input("Enter the number of 3 = ")
s4 = input("Enter the number of 4 = ")
s5 = input("Enter the number of 5 = ")
s6 = input("Enter the number of 6 = ")

st = [s1,s2,s3,s4,s5,s6]
st.sort()
print(st)

'''

#Q24. Check that tuple cannoy change in python.
'''
t = (1,2,3)
t[0] = 20
print(0)

'''


#Q25. Write a program to sum the list and list contain 4 variable.
'''
a = int(input("Enter The Number = "))
b = int(input("Enter The Number = "))
c = int(input("Enter The Number = "))
d = int(input("Enter The Number = "))

l = [a,b,c,d]
sum = sum(l)
print(sum)

'''

#Q26. Write s progrsm hoe msny zeros in a program.
'''
l = [1,0,8,0,909,0,908,8,0,]
a = l.count(0)
print(a)

'''

#Q27. Write a program to print english to print english the of land words entered by user.
#Q28. write a program to input eight no. with all have unique and print it.
'''
n1 = int(input("Enter The Number = "))
n2 = int(input("Enter The Number = "))
n3 = int(input("Enter The Number = "))
n4 = int(input("Enter The Number = "))
n5 = int(input("Enter The Number = "))
n6 = int(input("Enter The Number = "))

s = {n1,n2,n3,n4,n5,n6}

print(s)
'''

#Q28. Can we have with 18 int and 18 str as value.
'''
a={18,"18"}
print(a)

'''

#Q29. What is the syntax of empty sets.
'''
a = (())
print(type(a))

'''

#Q30. Write a program to create a dictionary allow 4 friend to enetr the value
# as language and use vaccum keys all names are different.
'''
f1 = input("Enter The aj = ")
f2 = input("Enter The pk = ")
f3 = input("Enter The kj = ")
f4 = input("Enter The pe = ")

d = {
"aj":f1,
"pk":f2,
"kj":f3,
"pe":f4
}
print(d)

'''

No comments:

Post a Comment