0% found this document useful (0 votes)
38 views16 pages

PP

The document contains examples of Python code that take user input, perform calculations and condition checks, and output results. The code snippets cover basic input/output, arithmetic operations, loops, strings, and other fundamental Python concepts.

Uploaded by

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

PP

The document contains examples of Python code that take user input, perform calculations and condition checks, and output results. The code snippets cover basic input/output, arithmetic operations, loops, strings, and other fundamental Python concepts.

Uploaded by

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

a=int(input())

b=int(input())

c=int(input())

print(a+b+c)

a=int(input())

print(a*a)

# Read the numbers b and h like this:

b = float(input())

l=float(input())

# Print the result with print()

print((b*l)/2)

# Read the name:

name = input()

# Print the result using:

# print('Greeting', name)

print("Hello"+"," +" "+name+"!")

# Read the numbers like this:

n = int(input())

k=int(input())

print(k//n)

print(k%n)

# Read the numbers like this:

n = int(input())

k=int(input())

print(k//n)

print(k%n)
fh=int(input())

fm=int(input())

fs=int(input())

fh1=int(input())

fm1=int(input())

fs1=int(input())

a=fh*3600+fm*60+fs

b=fh1*3600+fm1*60+fs1

print(b-a)

# Read an integer:

a = int(input())

# Read a float:

b = int(input())

# Print a value:

# print(a, b)

c = int(input())

if(a%2!=0):

a=(a//2)+1

else:

a=a//2

if(b%2!=0):

b=(b//2)+1

else:

b=b//2

if(c%2!=0):

c=(c//2)+1

else:

c=c//2

print(a+b+c)
# Read an integer:

a = int(input())

# Read a float:

# b = float(input())

# Print a value:

# print(a, b)

print(a%10)

# Read an integer:

a = int(input())

# Read a float:

# b = float(input())

# Print a value:

# print(a, b)

r=a%100

b=r//10

print(b)

# Read an integer:

a = int(input())

# Read a float:

# b = float(input())

# Print a value:

# print(a, b)

n=0

for i in range(3):

r=a%10

n=n+r

a=a//10

print(n)
import math

a=float(input())

b = math.fmod(a, 1.0)

c=round(b,10)

print(c)

a=float(input())

b=a-int(a)

print(int(b*10))

n = int(input())

m = int(input())

a=m/n

if(a!=int(a)):

a=(m//n)+1

else:

a=m//n

print(a)

import math

m = int(input())

h=m//60

a=(((m/60)%1)*60)

b=round(a)

print(str(h)+" "+str(b))

a = int(input())

b = int(input())

n = int(input())

d=a*n

c=b*n
m=c/100

m=int(m)

d=d+m

c=(((c/100)-int(c/100))*100)

print(d, c)

H = int(input())

M = int(input())

S = int(input())

angle=(H*30)+(M*0.5)+(S*(0.5/60))

print(angle)

a = float(input())

print(a%30*12)

# Read an integer:

a = int(input())

# Read a float:

b = int(input())

# Print a value:

# print(a, b)

if(a>b):

print(b)

else:

print(a)

# Read an integer:

a = int(input())

# Read a float:

# b = float(input())

# Print a value:
# print(a, b)

if (a>0):

print(1)

elif(a<0):

print(-1)

else:

print(0)

a=int(input())

b=int(input())

c=int(input())

if a<b:

if(a<c):

print(a)

else:

print(c)

else:

if(b<c):

print(b)

else:

print(c)

a=int(input())

b=int(input())

c=int(input())

if(a==b==c):

print(3)

elif(a==b) or (b==c) or(a==c):

print(2)

else:

print(0)
# Read an integer:

r1 = int(input())

c1= int(input())

r2= int(input())

c2= int(input())

if(c2==c1) or (r2==r1):

print('YES')

else:

print('NO')

r1=int(input())

c1=int(input())

r2=int(input())

c2=int(input())

if((r1+c1+r2+c2)%2==0):

print('YES')

else:

print('NO')

r1=int(input())

c1=int(input())

r2=int(input())

c2=int(input())

if((c2==c1) and ((r2==r1+1) or (r2==r1-1))):

print('YES')

elif((r2==r1) and ((c2==c1+1) or (c2==c1-1))):

print('YES')

elif((c2==c1+1) and (r2==r1+1)) or ((c2==c1-1) and (r2==r1-1)):

print('YES')
elif((c2==c1+1) and (r2==r1-1)) or ((c2==c1-1) and (r2==r1+1)):

print('YES')

else:

print('NO')

r1=int(input())

c1=int(input())

r2=int(input())

c2=int(input())

dx = abs(r2 - r1)

dy = abs(c2 - c1)

if (dx == dy) and (dx > 0):

print('YES')

else:

print('NO')

r1=int(input())

c1=int(input())

r2=int(input())

c2=int(input())

if (abs(r2 - r1)==abs(c2 - c1)):

print('YES')

elif(c1==c2):

print('YES')

elif(r1==r2):

print('YES')

else:

print('NO')
r1=int(input())

c1=int(input())

r2=int(input())

c2=int(input())

if(abs(r1-r2)==1) and (abs(c1-c2)==2):

print('YES')

elif(abs(r1-r2)==2) and (abs(c1-c2)==1):

print('YES')

else:

print('NO')

n = int(input())

m = int(input())

k = int(input())

if(n*m>=k):

if k%n==0 or k%m==0:

print('YES')

else:

print('NO')

else:

print('NO')

a = int(input())

if(a%400==0) or (a%100)!=0 and (a%4==0):

print("LEAP")

else:

print('COMMON')

a=int(input())

b=int(input())
for i in range(a,b+1):

print(i)

a=int(input())

b=int(input())

if(a<b):

for i in range(a,b+1):

print(i,end=' ')

else:

for i in range(a,b-1,-1):

print(i,end=' ')

sum=0

for i in range(10):

i=int(input())

sum=sum+i

print(sum)

n=int(input())

sum=0

for i in range(n):

sum=sum+int(input())

print(sum)

n=int(input())

sum=0

for i in range(n+1):

sum=sum+i*i*i

print(sum)
n=int(input())

fact=1

for i in range(1,n+1):

fact=fact*i

print(fact)

n=int(input())

count=0

for i in range(n):

i=int(input())

if(i==0):

count=count+1

print(count)

n=int(input())

sum=0

fact=1

for i in range(1,n+1):

fact=fact*i

sum=sum+fact

print(sum)

n=int(input())

for i in range(n):

num=1

for j in range(i+1):

print(num,end="")

num=num+1

print('\r')

n=int(input())
sum1 = 0

sum2 = 0

for i in range(1,n+1):

sum1 = sum1 + i

for i in range(1,n):

sum2 = sum2 + int(input())

print(sum1-sum2)

a=input()

print(a[2])

print(a[-2])

print(a[:5])

print(a[:-2])

print(a[::2])

print(a[1::2])

b="".join(reversed(a))

print("".join(reversed(a)))

print(b[::2])

print(len(a))

a=input()

count=0

for i in a:

if(i==' '):

count=count+1

print(count+1)

a=input()

b=len(a)

q,r=divmod(b,2)

f=a[:q+r]
l=a[q+r:]

print(l+f)

a=input()

s=a.split()

s=s[::-1]

t=' '.join(s)

print(t)

s=input()

n=len(s)

count=0

s1=s[::-1]

for i in s:

if(i=='f'):

count=count+1

if(count==1):

f=s.find('f')

print(f)

elif(count==0):

print('')

else:

f=s.find('f')

l=s1.find('f')

print(f,n-l-1)

s=input()

n=len(s)

count=0

for i in s:

if(i=='f'):
count=count+1

if(count==1):

print(-1)

elif(count==0):

print(-2)

else:

st=s.replace('f','r',1)

f=st.find('f')

print(f)

s=input()

f=s.find('h')

l=s.rfind('h')

str=s[f:l+1]

s=s.replace(str,'')

print(s)

s=input()

f=s.find('h')

l=s.rfind('h')

str=s[f:l+1]

st=str[::-1]

s=s.replace(str,st)

print(s)

a=input()

a=a.replace('1','one')

print(a)

a=input()

a=a.replace('@','')
print(a)

str = input()

a = str[:str.find('h') + 1]

b = str[str.find('h') + 1:str.rfind('h')]

c = str[str.rfind('h'):]

str = a + b.replace('h', 'H') + c

print(str)

a=input()

b=''

for i in range(len(a)):

if(i%3!=0):

b=b+a[i]

print(b)

n=int(input())

i=1

while(i*i<=n):

print(i*i)

i=i+1

n=int(input())

if n == 1:

print(1)

divisor = 2

while n % divisor != 0:

divisor += 1

print(divisor)

You might also like