0% found this document useful (0 votes)
25 views2 pages

.Py Basics

This document contains code snippets that: 1) Take user input, perform math operations, and print results; 2) Take user input, check for even/odd and value ranges to print output; 3) Take user input, use a for loop to print squared values; 4) Take user input, use a for loop and end parameter to print numbers; 5) Define a function to check if a year is a leap year; 6) Take multiple inputs, use nested for loops to generate a list of tuples excluding a sum, and print the list.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views2 pages

.Py Basics

This document contains code snippets that: 1) Take user input, perform math operations, and print results; 2) Take user input, check for even/odd and value ranges to print output; 3) Take user input, use a for loop to print squared values; 4) Take user input, use a for loop and end parameter to print numbers; 5) Define a function to check if a year is a leap year; 6) Take multiple inputs, use nested for loops to generate a list of tuples excluding a sum, and print the list.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

a = int(input())

b = int(input())
c=a+b
d=a-b
e=a*b
print(c)
print(d)
print(e)

n=int(input())
if (n%2):
print("Weird")
elif (n>=2 and n<=5):
print("Not Weird")
elif (n>=6 and n<=20):
print("Weird")
else:
print("Not Weird")

n=int(input())
for i in range(0,n):
print(i*i)

n = int(input())
for i in range(1,n+1):
print(i,end="")

def is_leap(year):
leap = False

# Write your logic here


if (year % 4 == 0 and year % 400 == 0):
leap = True
elif (year % 4 == 0 and year % 100 == 0):
leap = False
elif year % 4 == 0:
leap = True
return leap

x = int(input())
y = int(input())
z = int(input())
n = int(input())
list1=list(
[i,j,k]
for i in range(0,x+1)
for j in range(0,y+1)
for k in range(0,z+1)
if(i+j+k)!=n
)
print(list1)

You might also like