Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
12 views

Programs Python

Uploaded by

Aniket Parashar
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)
12 views

Programs Python

Uploaded by

Aniket Parashar
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/ 7

 ELSE & PRINT

1. PROGRAM 1

a = True
if a:
print("Hello Ayush")
else
print(" goodbye")

2. PROGRAM 2

a = 2
b = 3
if (b > a):
print("b is greater" )
elif (a > b):
print("a is greater ")
else :
print(" a and b are equal ")

3.

a = int(input("Enter your age "))


print("your age is: ",a)

if (a >18):
print("eligible for voting ")
else:
print("Not eligible for voting")

4.

var = 'r'
if var== 'a':
print("This is a vowel")
elif var== 'e':
print("This is a vowel")
elif var== 'i':
print("This is a vowel")
elif var== 'o':
print("This is a vowel")
elif var== 'u':
print("This is a vowel")
else :
print("this is a consonent")
VARIABLE:

var = 'r'
if var== 'a':
print("This is a vowel")
elif var== 'e':
print("This is a vowel")
elif var== 'i':
print("This is a vowel")
elif var== 'o':
print("This is a vowel")
elif var== 'u':
print("This is a vowel")
else :
print("this is a consonent")

a = 3
b = 4

num = 5
print(num)
type(num)

a = 6
b = 6
c = (a+b)
d = (a*b)
e = (a/b)
f = (a-b)
print("addition is",c,"multiplication is",d,"division is ",e,"subtraction
is",f )

a=6

b=6

c= a+b

print(c)
a = 60
b = 10
c = a/b
print(c)
print(type(c))

d=a+b
print(d)
print(type(d))

a= int(input("enter a number" ))

if a>0 :
print("number is positive")

elif a<0 :
print("number is negative")

else :
print("Zero number")

a=5
print("a=",5)

a=5=b
print("a=5","=b")

print("a=",5,"=b")
a= "TYRE"
print("a=",a,sep="9873" )
print('''======
WELCOME
======''')
print(''' =====
AYUSH AGRAWAL
=====''')
print("a=",7,"=b")
print("I want to be a programmer")
x = 5
y = 9
z = x * y
print(z)
print("codes"+"dopes")

x = 5 #swap
y = 20 #swap
x,y = y,x
print(x)
print(y)

a = 2
b = 4
c = a+b
print(c)

#import module
import calendar
year = 2024
month = 1

x = 6
y = 4
z = x+ y
print(z)

if(c % 2):
print("even")
else
print("odd")

c=int(input("enter a number."))
d=int(input("enter a number."))
print(d)
print(c)
b = (d + c)
a = (d * c)
g = (d - c)
f = (d / c)
print("addition is",b,"multiplication is",a, "subtaction is",g, "division is
",f)
print(type (b))

num =5
type(num)
#

c = int(input("enter first number: "))


d = int(input("enter secoand number: "))
print(d)
print(c)
b = d + c
print(type(b))
print("type of sum is",type (b))

num = 5
type(num)

ELSE IF

a = int(input("enter a number"))
b = int(input("enter a number"))

c=a+b
if(c>8):
print("c is greater")
elif (c<8):
print("c is smaller")
else :
print("error in c")

a = int(input("enter a number"))
b = int(input("enter a number"))

if(a>b):
c=a+b
print(c)
elif (a<b):
c=a-b
print(c)
else :
print("zero")
#TYPECASTING

#typecasting = the process of converting a value of one data type to another


name = "Rahul"
age = 21
gpa = 1.9
student = true

print(type(name))

a = 7
print(type(a)) ##program 1

s = 0.0
print(type(s))

b = 5.0
print(type(b)) ##program 2

c= a + b
print(c)
print(type(c)) ##program 3

x = int(1)
y = float(5.6)
z = int("4")
print(x)
print(y)
print(z) ##program 4

x = "Agrawal"
y = "Ayush"
x,y = y,x
print(x , y) ##program 5

x = "Agrawal"
y = "Ayush"
x,y = y,x
print(type(y)) ##program 6

a= 7
b= 9
d = a* - b
print(d)
print(type(d)) ##program 7
a = int(2)
b = int(2.5)
c = int("2")
print(a)
print(type(a))
print(b)
print(type(b))
print(c)
print(type(b)) ##program 8

str = "1500"
print("str data type:",type(str))

str_int = int(str)
print("str_int data type: ",type(str_int))
print(str_int)
print(str_int + 0.1) ##program 9

#typecasting = the process of converting a value of one data type to another


name = "Rahul"
age = 21
gpa = 1.9
student = True
c =a + b

print(type(c))
print(type(name))
print(type(age))
print(type(gpa))
print(type(student))

You might also like