Defined.: 1 CHAPTER 1 BASIC PROGRAMS Error! Bookmark Not
Defined.: 1 CHAPTER 1 BASIC PROGRAMS Error! Bookmark Not
Bookmark not
defined.
1.1 Print Your Name. .......................................... Error! Bookmark not defined.
1.2 Print greeting to someone by user input. ......... Error! Bookmark not defined.
1.3 Sum of 2 numbers y manual input. ................. Error! Bookmark not defined.
1.4 Multiplication of 2 numbers by user input. ...... Error! Bookmark not defined.
1.5 Sum of square of 2 numbers by using function. Error! Bookmark not defined.
1.6 Percentage of student marks from 3 subjects. ... Error! Bookmark not defined.
1.7 Area and volume of cube................................ Error! Bookmark not defined.
1.8 Convert distance in kms to meter, feet, yards and inches.Error! Bookmark not define
1.9 Swap two numbers without any temporary variable.Error! Bookmark not defined.
print("hello"+""+ a)
a=2
b= 6
print (a+b)
print(a*b)
def sum(x,y):
p = x*x+y*y
print p
sum(2,4)
#percentage of student marks from 3 subjects
perc = ((a+b+c)/300)*100
print perc
area = 6*a*a
volume = a*a*a
print(area)
print(volume)
yards = a*1093.61
inch = a*39370.1
meter = a*1000
feet = a*3280.84
print(yards)
print( inch)
print( meter)
print ( feet)
#swap two numbers without any temporary variable
x = 10
y=5
x = x + y; #x now becomes 15
y = x - y; #y becomes 10
x = x - y; #x becomes 5
if (a%2 == 0):
else:
def num(a):
if (a>0):
print("positive number")
else:
print("negative number")
num(4)
#to check larger of 2 numbers
if (a>b):
elif (b>a):
print("second is greater")
else:
else:
#Take two numbers as input and test whether two numbers are equal,Ist is
greater than second or lesser.
elif (b>a):
print("second is greater")
else:
a = float(raw_input("enter marks"))
if (a>100 or a<0):
if (a>=70):
print("pass")
if (a>90):
print("grade is A")
elif(a>80 or a<=90):
print("grade is B")
else:
print("fail")
if (a>100 or a<0):
#function to check the saved username and password of student and give
appropriate message if any of them is wrong
users = {}
status = ""
def displayMenu():
if status == "y":
oldUser()
newUser()
def newUser():
createLogin = raw_input("Create login name: ")
else:
print("\nUser created!\n")
def oldUser():
else:
displayMenu()
newUser()
oldUser()
#function to enter the age of a person and check if he is elligible for work.
def work(age):
if (age<18):
else:
print("you are too old to work as per the rules of the government")
work(33)