Vous êtes sur la page 1sur 4

1. A Robot moves in a Plane starting from the origin point (0,0).

The robot can


move
toward UP, DOWN, LEFT, RIGHT. The trace of Robot movement is as given
following:
UP 5
DOWN 3
LEFT 3
RIGHT 2
The numbers after directions are steps. Write a program

a=0
b=0
for i in range(4):
x = int(input("number of step :"))
y = (input("Enter the direction :"))
if y=="up":
a=a+x
elif y=="right":
a=a+x
elif y=="down":
b=b+x
elif y=="left":
b=b+x

print(a,b)
print("area covered by Robot :",(a**2+b**2))

2. Data of XYZ company is stored in sorted list. Write a program for searching
specific data from that list.

company_data = ['book','pencil','pen','note book','sharpener','rubber']


item = input('What item do you want to check for in the bag?')

for i in range(1):
if item in company_data:
print('Item is in company data')
break
else:
print("data is not available")

3.Weather forecasting organization wants to show is it day or night. So, write a


program for such organization to find whether is it dark outside or not.

4.
from math import radians,sin,cos,acos
import math

print("Input coordinates of two points:")


Point_A_Lat=radians(float(input("Enter Point A : Lat")))
Point_A_Long=radians(float(input("Enter Point A : Long")))
Point_B_Lat=radians(float(input("Enter Point B : Lat")))
Point_B_Long=radians(float(input("Enter Point B : Long")))

x=6371*(math.acos(math.sin(Point_A_Lat)*math.sin(Point_B_Lat)
+math.cos(Point_A_Lat)*math.cos(Point_B_Lat)*math.cos(Point_A_Long-Point_B_Long)))
print("The distance is:",x,"km")

5.Design a software for bank system. There should be options like cash withdraw,
cash credit and change password. According to user input, the software should
provide required output

print("Print welcom to the bank___ xyz___")


print("Please insert your card")
password=input("Please enter your 4 digit ATM password")

ATM_Password="1234"
amount_in_bank=50000

if ATM_Password in password:
print("welcom to the bank ___xyz____")
z = input("do you want to withdaw amount :")
if z == "yes":
withdraw = int(input("Please input the amount to withdraw :"))
if withdraw <= amount_in_bank:
print("please collect your cash :", withdraw)
amount_in_bank=amount_in_bank-withdraw
print("Available balance in Account :",amount_in_bank)

else:
print("You dont have limit")

else:
m = input("do you want to credit amount :")
if m == "yes":
credit = int(input("Please input the amount to credit :"))
amount_in_bank += credit
print("Account has been credit with :", credit)
print("your balance in Account=", amount_in_bank)
else:
n = input("Do you want to change the password :")
if n == 'yes':

Old_pass =(input("Please enter your old password :"))

if ATM_Password in Old_pass:
new_pass = input("Please enter new 4 digit password :")
print("your new passowrd is =",new_pass)
else:
print("password is incorrect")
else:
print("password is incorrect")

else:
print("Please try again")

6. Write a program which will find all such numbers which are divisible by 7 but
are
not a multiple of 5, between 2000 and 3200 (both included). The numbers obtained
should be printed in a comma-separated sequence on a single line.
for i in range(2000,3200):
if i%7==0 and i%5==0:
print(i)

7.

8.Write a program that calculates and prints the value according to the given
formula:
Q = Square root of [(2 * C * D)/H]
Following are the fixed values of C and H: C is 50. H is 30.
D is the variable whose values should be input to your program in a commaseparated
sequence.

import math

C= 50
H = 30
Ds = []
result =[]
Dv=input("enter the value of D")
Ds=Dv.split(",")
Ds = [int(i) for i in Ds]
i=0
l = len(Ds)
while(i<l):
Q = round(math.sqrt((2*C*Ds[i])/H))
result. append(Q)
i+=1
print("output=",result)

10.Write a program that accepts a comma separated sequence of words as input and
prints the words in a comma-separated sequence after sorting them alphabetically.
Suppose the following input is supplied to the program:
without,hello,bag,world
Then, the output should be:
bag,hello,without,world

x=input("Enter the wordd")


y=sorted(x.split(","))

print(y)

11..Write a program that accepts sequence of lines as input and prints the lines
after
making all characters in the sentence capitalized.
Suppose the following input is supplied to the program:
x=input("Enter the wordd ")
y=[]

for i in range(1):
y.append(x.upper())

print(y)

12..Write a program that accepts a sequence of whitespace separated words as input


and prints the words after removing all duplicate words and sorting them
alphanumerically

x=input("Enter the wordd ")


x=x.split(" ")
y=set(x)
y=sorted(y)
print(y)

14.Write a program that accepts a sentence and calculate the number of upper case
letters and lower case letters.

x=input("Please enter the word")


upper=0
lower=0
for i in x:
if (i.isupper()):
upper=upper+1
elif(i.islower()) :
lower+=1
print("upper latters :",upper)
print("Lower latters :",lower)

Vous aimerez peut-être aussi