0% found this document useful (0 votes)
13 views21 pages

Computer Problems

The document provides a comprehensive set of algorithms and Python programs for various mathematical and logical operations, including calculating areas, simple interest, and performing arithmetic operations. It includes pseudocode and Python code for tasks such as swapping values, checking even/odd numbers, and finding averages. Additionally, it covers control flow structures like loops and conditionals to manage user input and output.

Uploaded by

memesky2099
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views21 pages

Computer Problems

The document provides a comprehensive set of algorithms and Python programs for various mathematical and logical operations, including calculating areas, simple interest, and performing arithmetic operations. It includes pseudocode and Python code for tasks such as swapping values, checking even/odd numbers, and finding averages. Additionally, it covers control flow structures like loops and conditionals to manage user input and output.

Uploaded by

memesky2099
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 21

INTRODUCTION TO PROBLEM SOLVING​

(WAA - Write an Algorithm)​



WAA to find the area of a rectangle​
1. Start​
2. Read l,b​
3. Calculate area ← l*b​
4. Print “The area of the rectangle”, area​
5. Stop​

WAA an algorithm to evaluate the expression (A+B-C*D)²​
1. Start​
2. Read A,B,C,D​
3. Calculate q ← C*D​
4. Calculate p← A+B​
5. Calculate r←p-q​
6. Calculate s ← r*r​
7. Print s​
8. Stop​

WAA to complete a simple interest​
1. Start​
2. Read P,R,T​
3. Calculate S← P*R*T​
4. Calculate V ← S/100​
5. Print “The simple interest”, V​
6. Stop​

WAA to accept two numbers and swap their values​
1. Start​
2. Read A,B,C​
3. Assign C←A​
4. Assign A←B​
5. Assign B←C​
6. Print “Swapped values”, A,B​
7. End​

WAA two numbers and check whether the quotient is more than 10​
1. Start​
2. Read A,B​
3. Compute ← A/B​
4. if x>10 then​
​ print “Quotient is greater than 10”​
5. else​
​ print “Quotient is lesser than 10”​
6. Stop​

WAA to check whether the given number is even or odd.​
1. Start​
2. Read A​
3. Calculate x ← A%2​
4. If x = 0 then​
​ Print “Even”​
5. else​
​ print”odd”​
6.stop​

WAA to read give marks of a student, find the average and assign the grade according to the given criteria​
if average more than 90 grade ← ’A’​
b/w 40-90 grade ← ’B’​
Below 40 grade ← ’C’​

1.Start​
2.Read A,B,C,D,E​
3. Compute avg←(A+B+C+D+E)/5​
4. If avg > 90 then​
​ grade←’A’​
5. else avg ≥40 and avg ≤ 90 then/​
​ grade←’B’​
6. else avg ≤ 40​
​ grade←’C’​
7. Print (grade)​
8. Stop​

WAA to print even numbers between 1 and n​
1. Start​
2. Read n​
3. for i in 1-n​
​ if i%2=0​
​ Print i​
4.Stop​

WAA to print the numbers ranging from m-n.​
Eg: if m is 10 and n - 15, the algorithm should print 10,11,12,13,14,15​
1. Start​
2. Read m,n​
3. Assign i←m​
4. while i<=n​
​ print i​
i=i+1​
5. Stop​

WAA to find the sum of 1-n​
1. Start ​
2. Read n​
3. S←0​
4. for i in 1-n​
​ s←s+i​
5. print s​
6. Stop​



WAA to find the sum of even numbers​
1. Start​
2. Read n​
3. a←0​
4. for i in 1-n​
​ if i%2=0​
​ a←a+i​
5. print a​
6. Stop​

WAA to print product of odd numbers b/w m and n​
1. Start​
2. Read m,n​
3. a←1​
4. for i in m-n​
​ if i%2 != 0​
​ a←a*i​
5. print a​
6. Stop​

WAA to find the factorial of an accepted number​
1. Start ​
2. Read n​
3. fact←1​
4. for i in 1-n​
​ fact←fact*i​
5. print fact​
6. stop​

WAA to find the product of all factors of an accepted number​
1. Start​
2. Read n​
3. p←1​
4. for i in 1-n​
​ If n%i =0​
​ p ← p*i​
5. print p​
6. stop​

PSEUDOCODE​
WTP - to evaluate an expression (A+B)^n+m^n​
INPUT A,B,m,n​
COMPUTE C=(A+B)^n​
COMPUTE D=(C+m)^n​
PRINT D​

WTP to find the different between two numbers and ensure that the result is not negative​
INPUT A,B​
IF A>B​
print A-B​
else print B-A​

WTP to print the last digit of the accepted Number​
INPUT A​
COMPUTE B = A%10​
PRINT B​

WTP to accept a number and check whether it is a single digit number, if so print a message “single digit” or “Two
digits” otherwise a message “Big number”​
INPUT N​
If N>10​
Print “single digit”​
else if N<100​
Print “Two digits”​
else if N>100​
Print “Big Number”​

WTP that will perform the following task, read the marks of 3 subjects​
Calculate the total mark​
Calculate the percentage of mark​
INPUT X,Y,Z​
COMPUTE a= X+Y+Z​
COMPUTE b=a/3​
PRINT a,b,X,Y,Z​

WTP to find the area of a rectangle and square ​
INPUT L,B,s​
COMPUTE a=L*B​
COMPUTE b=s*s​
PRINT a,b​

GETTING STARTED WITH PYTHON​
(WAP - Write a program)​

WAP to accept 2 numbers (integers and find the sum, difference, product, quotient, integer quotient, remainder,
exponential)​
a=int(input(“Enter a number:”))​
b=int(input(“Enter another number:”))​
s=a+b​
d=a-b​
p=a*b​
q=a/b​
i=a//b​
r=a%b​
e=a**b​
print(“Sum”,s)​
print(“Difference”,d)​
print(“Product”,p)​
print(“Quotient”,q)​
print(“Integer Quotient”,i)​
print(“Remainder”,r)​
print(“exponential”,e)​

WAP to accept sides of the various shapes (rectangle, square, and triangle) and find its area.​
ln = int(input(“Enter the length:”))​
br=int(input(“Enter the breadth:”))​
sd=int(input(“Enter the side:”))
bs=int(input(“Enter the base:”))​
ht=int(input(“Enter the height:”))​
ar=ln*br​
sq=sd*sd​
tr=½*bs*ht​
print(“The area of rectangle", ar)​
print(“The area of square”, sq)​
print(“The area of triangle”, tr)​

WAP to accept two integers to swap their values (using third variable)​
a=int(input(“Enter a number:”))​
b=int(input(“Enter another number;”))​
a,b=b,a​
print(“Swapped Values”, a,b)​

WAP to find the simple interest and total amount to be paid​
P=int(input(“Enter the principle amount:”))​
R=int(input(“Enter the rates:”))​
T=int(input(“Enter the number of years:”))​
SI=(P*R*T)/100​
Total=P+SI​
print(“The simple interest and Total Amount:”, SI, Total)​

WAP to accept an amount less than 50 and display the number 20, 10, 5, 2 and 1 rupee notes within the accepted
amount.​
amt = int(input(“Enter an amount less than 50:”))​
n20=amt//20​
amt=amt%20​
n10=amt//10​
amt=amt%10​
n5=amt//5​
amt=amt%5​
n2=amt//2​
amt=amt%2​
n1=amt//1​
amt=amt%1​
Print(“Number of 20 rupees notes:”, n20)​
Print(“Number of 10 rupees notes:”, n10)​
Print(“Number of 5 rupees notes:”, n5)​
Print(“Number of 2 rupees notes:”, n2)​
Print(“Number of 1 rupees notes:”, n1)​

WAP to accept number of days and find the number of years, months, weeks and remaining days​
a=int(input(‘Enter the number of days:”))
y=a//365​
a=a%365​
m=a//30​
a=a%30​
w=a//7​
a=a%7​
print(“Number of years”,y)​
print(“Number of months”,m)​
print(“Number of weeks”,w)​
print(“Number of days”,a)​

WAP to accept a three digit number and display the digits separately.​
n=int(input(“Enter a 3 digit number:”))​
x=n%10​
n=n//10​
y=n%10​
n=n//10​
print(“The digits are:”, N,y,x)​

WAP to accept 3 integers and find the average.​
a=int(input(“Enter a number:”))​
b=int(input(“Enter second number:”))​
c=int(input(“Enter third number:”))​
avg=a+b+c/3​
print(“The average of 3 numbers:”,avg)​

WAP to accept a 4 digit number and find the sum of the number​
n=int(input(“Enter a 4 digit number:”))​
x=n%10​
n=n//10​
y=n%10​
n=n//10​
z=n%10​
n=n//10​
S=N+x+y+z​
Print(“Sum of Numbers:”,S)​

WAP to accept a 3 digit number and display the reversed number​
N=int(input(“Enter a 3 digit number:”))​
x=n%10​
n=n/10​
y=n%10​
n=n//10​
print(“The reversed number:”, x*100+y*10+N)​

WAP to accept the temperature in celsius and convert it into fahrenheit​
TF=Tc*9/5+32​
Tc=int(input(“Enter the temperature:”))​
print(“The temperature in Fahrenheit:”, Tc*9/5+32)​

WAP to repeat the string “GOOD MORNING” n times​
n=int(input(“Enter the value of n:”))​
print(“GOOD MORNING”*N)​








FLOW OF CONTROL​

WAP to accept a number and check whether it is positive, negative and zero​
num=int(input(“Enter a number:”))​
if num>0:​
​ print(“number is positive”)​
Elif num<0:​
​ print(“number is negative”)​
else:​
​ print(“number is zero”)​

WAP to accept the colour of the signal and print the message Go/ Wait/ Stop​
colour=input(“Enter the signal colour:”)​
if colour==”green” or ”GREEN” or ”Green”​
​ print(“GO”)​
elif colour==”yellow” or ”YELLOW’ or ”Yellow”​
​ print(“WAIT”)​
elif colour==”red” or “RED” or “Red”​
​ print(“STOP”)​
else:​
​ print(“Invalid colour”)​

WAP to print the numbers ranging from 1-n where n is accepted during runtime.​
n=int(input(“Enter the limit:”))​
for i in range(1,n+1):​
​ print(i)​

WAP to print n multiples of x​
n=int(input(“Enter the value of n:”))​
x=int(input(“Enter the value of x:”))​
for i in range(1,n+1)​
​ print(x*i)​

WAP to print the multiplication table of x, ‘n’ times​
n=int(input(“Enter the value of n:”))​
x=int(input(‘Enter the value of x:”))​
for i in range(1,n+1):​
​ print(i,”*”, x. “=”, x*i)​

WAP to print the numbers ending from 1-n. Both 1 and n are inclusive. n should be accepted during runtime​
n=int(input(“Enter the value of n:”))​
for i in range(1,n+1):​
​ print(i)​


WAP to print all the even numbers between 1 and n​
n=int(input(“Enter the value of n:”))​
for i in range(1,n+1):​
​ if i%2=0:​
​ print(i)​


WAP to accept two numbers and an operator and do all the arithmetic operations based on the operator accepted.​
a=int(input(“Enter a number:”))​
b=int(input(“Enter another number:”))​
oper=input(“Enter an operator(+,-,*,/,**,//,%)​
if oper == ‘+’:​
​ print(“Sum”, a+b)​
elif oper == ‘-’:​
​ print(“Difference”, a-b)​
elif oper == ‘*’:​
​ print(“Product”, a*b)​
elif oper == ‘/’:​
​ print(“Quotient”, a/b)​
elif oper == ‘%’:​
​ print(“Remainder”, a%b)​
elif oper == ‘//’:​
​ print(“Floor division”, a//b)​
elif oper == ‘**’:​
​ print(“Exponent”, a**b)​
else:​
​ print(“Invalid Operator”)​

WAP to accept a number and check whether it is even or odd, if its an even number print the cube otherwise a
square.​
n=int(input(“Enter the value of n:”))​
if n%2==0​
​ print(“The cube of the even number:”,n**3)​
else:​
​ print(“The square of the odd number:”,n**2)​

Wap to accept a string and the number of times n and print the string n times in the format given below:​
example Output​
String=”Hello” HelloHelloHello ​
n=3 HelloHelloHello ​
HelloHelloHello ​


n=int(input(“Enter the number of times:”))​
s=input(“Enter the string:”))​
for i in range(n)​
print(s*n)​

WAP to accept n integers and find the sum of n accepted number​
n=int(input(“Enter the value of n:”))​
s=0​
for i in range(n):​
​ num=int(input(“Enter a number:”))​
​ s=s+num​
print(“Sum of accepted number:”, s)​

WAP to accept n numbers and find the product.​
n=int(input(‘Enter the value of n:”))​
p=1​
for in in range(n0​
​ num=int(input(“Enter a number:”))​
​ p=p*num​
print(“product of numbers:”, p)​

WAP to display the sum of even numbers and odd numbers separately within the list of n numbers.​
n=int(input(“Enter the value of n:”))​
se=0​
so=0​
for i in range(n):​
​ x=int(input(“Enter the value of x:”))​
​ if x%2==0:​
​ se+=x​
​ elif x%2!=0:​
​ so+=x​
​ print(“Sum of even and odd numbers”, se, so)​

WAP to accept n numbers and print those numbers which are even​
n=int(input(“Enter the value of n:”))​
for i in range(1,n+1):​
​ x=int(input(“Enter the value of x:”))​
​ ​ if x%2==0:​
​ ​ ​ print(“Number is even”, x)​

WAP to print those numbers which are ending with 3 among ‘n’ accepted numbers​
n=int(input(“Enter the value of n:”))​
for i in range(1,n+1):​
​ x=int(input(“Enter the value of x:”))​
​ ​ if x%10==3:​
​ ​ ​ print(“Number ends with 3”, x)​
WAP TO ACCEPT N NUMBERS AND FIND THE LARGEST​
n=int(input(“Enter the value of n:”))​
large=0​
for i in range(n):​
​ num=int(input(“Enter a number:”))​
​ if num>large​
​ large=num​
print(“The largest is”, large)​

WAP to accept n numbers and find the smallest​
n=int(input(“Enter the value of n:”))​
small=0​
for i in range(n):​
​ num=int(input(“Enter a number:”))​
​ if num<small​
​ small=num​
print(“The smallest is”, small)​

WAP to print a fibonacci series of n terms​
n=int(input(“Enter the value of n:”))​
f=0​
s=1​
print(f,s, end=’ ‘)​
for i in range(3,n+1):​
​ t=f+s​
​ print(t,end=’ ‘)​
​ f=s​
​ s=t​

WAP to accept a number and check whether it is a prime number​
n=int(input(“Enter the value of n:”))​
for i in range(2,n):​
​ if n%2==0:​
​ print(“Number is not prime”)​
​ break;​
else:​
​ print(“Number is positive”)​

WAP to accept a number and display the digits​
n=int(input(“Enter a number:”))​
r=2​
while n>r:​
​ r=n%10​
​ n=//10​
​ print(r, end=’,’)​
WAP to accept a number and print the sum of the digit​
n=int(input(“Enter the value of n:”))​
s=0​
while n>0:​
​ r=n%10​
​ s=s+r​
​ n=n//10​
print(“Sum of the digits”,s)​

WAP to print the asterisk symbol (*) n times in the pattern given below​
*​
**​
***​
n=int(input(“Enter the value of n:”))​
for i in range(1,n+1):​
print(‘*’*i)​

WAP to print the pattern given below for the value n is 4​
1​
12​
123​
1234​
n=int(input(“Enter the value of n:”))​
for i in range(1,n+1):​
​ for j in range(1,i+1):​
​ ​ print(j,end=’ ‘)​
​ print( )​

WAP to print the pattern given below for the value n is 4​
1​
22​
333​
4444​
n=int(input(‘Enter the value of n;”))​
for i in range(1,n+1):​
​ for j in range(1,i+1):​
​ ​ print(i, end=’ ‘)​
​ Print (i)​

WAP to accept a number and reverse the number​
n=int(input(“Enter a number:”))​
rev=0​
while n>0:​
​ r=n%10​
​ n=n//10​
​ rev=rev*10+r​
print(rev)​

WAP to check whether the number is a palindrome.​
n=int(input(“Enter a number:”))​
rev=0​
a=n​
while n>0:​
​ r=n%10​
​ n=n//10​
​ rev=rev*10+R​
if a==rev:​
​ print(“Number is a palindrome”)​
else:​
​ print(“Number is not a palindrome”)​

WAP to check whether the accepted number is Armstrong number ​
(The sum of the cubes of each digit gives you the original number)​
n=int(input(“Enter the value of n:”))​
s=0​
a=n​
while n>0:​
​ r=n%10​
​ s+=(r**3)​
​ n=n//10​
if a==s:​
​ print(“The number is Armstrong’)​
else:​
​ print(“The number is not Armstrong”)​

WAP to accept a number and find the product of 1-n.​
n=int(input(“Enter a number:”))​
f=1​
for i in range(1,n+1):​
​ f=f*i​
print(“factorial”, f)​

WAP to find the sum of given series of n terms 2+4+6+...n terms​
n=int(input(“Enter the value of n:”))​
s=0​
x=2​
for i in range(1,n+1):​
​ s+=x​
​ x+=2​
print(“Sum of the series”,s)​

WAP to find the sum of given series of n terms of 2/1x + 4/3x + 6/5x+ … n terms​
n=int(input(“Enter the number:”))​
x=int(input(“Enter the value of x:”))​
s=0​
d=1​
num=2​
for i in range(1,n+1):​
​ s=s+num/d*x​
​ num+=2​
​ d+=2​
print(‘Sum of series”, s)​

MENU DRIVEN OF FLOW OF CONTROL also important​

STRINGS​

WAP to accept a string and display the number of capital alphabets, small letter alphabets and other characters
separately.​
s=input(“Enter a string:”)​
cu=cl=cd=cc=0​
for i in s:​
​ if i.isupper():​
​ ​ cu+=1​
​ elif i.islower():​
​ ​ cl+=1​
​ elif i.isdigit():​
​ ​ cd+=1​
​ else:​
​ ​ cc+=1​
print(“Number of uppercase:”, cu)​
print(“Number of lowercase:”, cl)​
print(“Number of digits:”, cd)​
print(“Number of other characters:”, cc)​

WAP to display the number of vowels (any one) with the accepted string.​
s=input(“Enter a string:”)​
c=0​
for i in s:​
​ if i in “aeiouAEIOU”​
print(“Number of vowels”, c)​


WAP to accept a string and a character and display the number of times the character is present within the string​
s=input(“Enter a string;”)​
ch=input(“Enter a character:”)​
x=s.count(ch)​
print(“Number of times”, x)​

WAP to accept a string and display the number of words present in the string, each word is separated by the space.​
s=input(“Enter the string:”)​
print(“Number of words:”, s.count(‘ ‘)+1)​

WAP to accept a string and display the first, last and middle character of the accepted string.​
s=input(“Enter the string:”)​
print(“The first character”, s[0])​
print(“The middle character”, s[-1])​
print(“The last character”, s[len(s)//2])​

WAP to accept a string and replace every occurrence of the given character with an * symbol​
s=input(“Enter the string:”)​
a=input(“Enter a character:”)​
x=s.replace(a,’*’)​
print(“The string”, x)​

WAP to check whether the string is a palindrome​
s=input(“Enter the string:”)​
n=s[-1::-1]​
if s==n:​
​ print(“String is a palindrome”)​
else:​
​ print(“String is not a palindrome”)​

WAP to accept a string and replace every occurrence of the character with a given character. The program should
accept the string, the character to be searched and the character to be replaced.​
s=input(“Enter the string:”)​
ch=input(“Enter the character to be replaced:”)​
n=input(“Enter the new character:”))​
str=s.replace(ch,n)​
print(str)​

WAP to accept a string containing alphabets and digits and display the sum of digits within the string.​
s=input(“Enter the string:”)​
sum=0​
for i in s:​
​ if i.isdigit():​
​ ​ sum=sum+int(i)​
print(“Sum of the digits”, sum)​
.​
.​
.​
.​



LISTS​

WAP to print the even elements within a list defined below​
L = [10,5,3,9,25,15,18,16,17]​
L = [10,5,3,9,25,15,18,16,17]​
for i in L:​
​ if i%2==0:​
​ ​ print(i)​

WAP to repeat or replicate a list if the list contains at least one odd element. The list is defined below:​
L = [10,11,51,2,29,24]​
L = [10,11,51,2,29,24]​
for i in L:​
​ if i%2!=0​
​ ​ print(L*3)​

WAP to accept a list and print the sum of the list elements.​
L=[ ]​
n=int(input(“Enter the value of n;”)​
for i in range(n):​
​ num=int(input(“Enter a number;”))​
​ L.append(num)​
print(“Sum of elements”, sum(L))​

WAP to accept a list of n integers and increment the even numbers by 1 and decrement the odd numbers by 1​
L=[ ]​
n=int(input(“Enter the value of n:”))​
for i in range(n):​
​ num=int(input(“Enter a number:”))​
​ L.append(num)​
for i in range(n):​
​ if L[i]%2==0:​
​ ​ L[i]=L[i]+1​
​ else:​
​ ​ L[i]=L[i]-1​
print(L)​

WAP to accept a list of n integers and replace every odd number with its cube. The program should finally display
the list​
L=[ ]​
n=int(input(“Enter the value of n:”))​
for i in range(n):​
​ num=int(input(“Enter a number:”))​
​ L.append(num)​
for i in range(len(L))​
​ if L[i]%2!=0​
​ ​ L[i]=l[i]**3​
print(“The new list:”, L)​

WAP to accept a list of L integers, modify the list such that the elements of the list are shifted towards the left.​
L=[ ]​
n=int(input(“Enter the value of n:”))​
for i in range(n):​
​ num=int(input(“Enter a number:”))​
​ L.append(num)​
x=L.pop(0)​
L.append(x)​
print(“The resultant list”, L)​

WAP to find the number of times an element occurs in the list with or without built in function​
L=[ ]​
n=int(input(“Enter the value of n:”))​
for i in range(n):​
​ num=int(input(“Enter a number:”))​
​ L.append(num)​
x=int(input(“Enter the value of x:”))​
c=L.count(x)​
print(“The number of times the element appears:”, c)​

WAP to accept a list of n integers. Create 2 new lists, one having positive numbers and other having negative
numbers from the given list. Print all 3 lists​
L1=[ ]​
L2=[ ]​
L3=[ ]​
n=int(input(“Enter the value of n:”))​
for i in range(n):​
​ num=int(input(“Enter a number:”))​
​ L.append(num)​
for i in L1:​
​ if i>0:​
​ ​ L2.append(i)​
​ elif i<0:​
​ ​ L3.append(i)​
print(“The original list”, L1)​
print(“The list containing positive integers”, L2)​
print(“The list containing negative integers”, L3)​




TUPLES​

WAP to accept a tuple of n integers and display the sum of all elements.​
tpl=()​
n=int(input(“Enter the value of n:”))​
for i in range(n):​
​ num=int(input(“Enter a number;”))​
​ tpl=tpl+(num,)​
print(“Sum of tuple elements”, sum(tpl))​

WAP to accept a tuple of n integers and display the first and the last element.​
n=int(input(“Enter the value of n:”))​
for i in range(n):​
​ num=int(input(“Enter a number;”))​
​ tpl=tpl+(num,)​
print(“The first element”, t[0])​
print(“The last element”, t[n-1])​

WAP to accept a tuple of n integers and display the middle element. (Assume size of tuple is odd)​
n=int(input(“Enter the value of n:”))​
for i in range(n):​
​ num=int(input(“Enter a number;”))​
​ tpl=tpl+(num,)​
print(“Middle element:”, t[n//2])​

WAP to accept a tuple of integers and display the number of occurrences of the given element within the tuple.​
n=int(input(“Enter the value of n:”))​
for i in range(n):​
​ num=int(input(“Enter a number;”))​
​ tpl=tpl+(num,)​
x=int(input(“Enter the value of x:”))​
print(“Number of times the element occurs:”, tpl.count(x))​




#DICTIONARY

1
'''
d={}
n=int(input("Enter the limit: "))
for i in range(n):
rollno=int(input("Enter the student's roll number: "))
name=input("Enter the name of the student: ")
d[rollno]=name
print(d)
'''​
2
'''
d={}
n=int(input("Enter the limit: "))
c=0
for i in range(n):
eno=int(input("Enter the employee number: "))
ename=input("Enter the employee name: ")
salary=int(input("Enter the salary of the employee: "))
d[eno]=[ename, salary]
for eno in d:
if d[eno][1] > 50000:
c=c+1
print(c)
'''
3
'''
d={}
d={}
n=int(input("Enter the limit: "))
c=0
for i in range(n):
eno=int(input("Enter the employee number: "))
ename=input("Enter the employee name: ")
salary=int(input("Enter the salary of the employee: "))
d[eno]=[ename, salary]
for k,v in d.items():
if v[1]>50000:
c=c+1
print("The total number of employees with salary more than 50 dough: ", c)​
'''​

4
'''

d={}
n=int(input("Enter the limit: "))
for i in range(n):
ename=input("Enter the employee name: ")
salary=int(input("Enter the salary of the employee: "))
d[ename]=[salary]
for k,v in d.items():
if v[0]>50000:
print(k,v)
'''​
5
'''
d={}
n=int(input("Enter the limit: "))
for i in range(n):
name=input("Enter the name: ")
phno=int(input("Enter the phone number: "))
d[name]=[phno]
for k,v in d.items():
print(k,v)
'''​
6
'''
S={}
n=int(input("Enter the limit: "))
for i in range(n):
name=input("Enter the name: ")
Eng=int(input("Enter the marks of english: "))
Math=int(input("Enter the marks of math: "))
Science=int(input("Enter the marks of science: "))
S[name]=[Eng,Math,Science]
for k,y in S.items():
avg=sum(y)//3
if avg>=90:
print("Grade A")
elif avg<90 and avg>=60:
print("Grade B")
else:
print("Grade C")

'''
7​
'''

d={}
n=int(input("Enter the limit: "))
c=0
for i in range(n):
eno=int(input("Enter the employee number: "))
ename=input("Enter the employee name: ")
exp=int(input("Enter the number of years of experience: "))
salary=int(input("Enter the salary of the employee: "))
d[eno]=[ename, exp, salary]
for k,v in d.items():
if v[1]>0 and v[2]>90000:
c=c+1
print("The number of experience employees with salary more than 90000: ", c)

'''
8. MENU DRIVEN
'''

d=eval(input("Enter the country & capital as a dictionary {country : capital,...}"))


while True:
ch=int(input("1.print capital\n 2. print country \n Enter your choice: "))
if ch==1:
c=input("Enter the name of the country: ")
if c in countcap:
print(d[c])
elif ch==2:
c=input("Enter the name of the capital; ")
for k,v in d.items():
v==d
print("The country is", k)
else:
print("Invalid choice")
'''

You might also like