GUPTA MECHANICAL

IN THIS WEBSITE I CAN TELL ALL ABOUT TECH. TIPS AND TRICKS APP REVIEWS AND UNBOXINGS ALSO TECH. NEWS .............

Sunday 8 November 2020

Class 12th sumita arora solutions || Chapter 1- Python Revision tour - 1 || Type- C


Q 1 = write a program to print one of  the words negative ,zero or positive . according to whether variable x is less than 0 , 0 or greater than 0 respectively .

Answer = 

x = int (input ("enter the number "))
if  x > 0:
    print ("positive number ")
elif x == 0 :
    print ("zero number ")
else :
    print ("nigative number ")



Q2 = write a program that return True if the input number is an even number , False otherwise .


Answer =

x = int (input ("enter the number "))

if x%2 == 0:
    print ("true ")

else :
    print (" false ")



Q 3 = Write a python program that calculates and prints the number of seconds in a year .

Answer = 


print ( "for non leap year = " ,60*60*24*365, " , for leap year = ", 60*60*24*366 )



Q 4 =  Write a python program that accepts two integers from the user and print a message saying if first number is divisible by second number or if it is not .


Answer =

first = int(input("enter the first number "))
second = int(input("enter the second number "))

if first % second == 0 :
    print ("first number is divisible by second number ")

else :
    print ("first number is not divisible by second number ")



Q 5 = write a program that ask the user the day number in the year in the range 2 to 365 and ask the first day of the year Sunday or Monday or Tuesday e.t.c . then the program should display the day on the day number that has been input .


Answer =


d = {"Sunday":1,"Monday":2,"Tuesday":3,"Wednesday":4,"Thursday":5,"Friday":6,"Saturday":7}

days = { 1 :"Sunday",2:"Monday",3:"Tuesday",4:"Wednesday",5:"Thursday",6:"Friday",7:"Saturday"}

dic= { }

user = int(input("Enter a number between 2 to 365 = "))

day = input("Enter first day of year (Sunday, Monday, Tuesday,Wednesday,Thursday,Friday,Saturday)")

first = d[day]
print(first)

for j in range(1,366) :
        dic[ j ] = first
        if first == 7 :
            first = 0
        first += 1

a = dic[ user ]

print(days [ a ])




Q 6 = one foot equals 12 inches . write a function that accept a length written in feet as an argument  and returns this length written in inches . write a second function that ask the user for a number of feet and return this value . write a third function that accept a number of inches and display this to the screen . use these three functions to write a program that asks the user for a number of feet and tells them the corresponding number of inches .


Answer:-

def inch(feet):  						#1
	return feet*12
	
def ask():							#2
	ft=int(input("enter number in feet "))
	return ft 
	
def inch2(inch):
	print(inch)
	
inch2(inch(ask()))	



    

Q7 = Write a program that reads an integer N from the keyboards computes and displays the sum of numbers from N to (2*N) if N is nonnegative. If N is a negative number , then it’s the sum of the numbers from (2*N) to N . the starting and ending points are included in the sum .


Answer:-


sum = 0

n = int(input("enter the number "))

if n > 0 :
    for i in range (n,n*2+1):
        sum += i
else :
    for i in range (2*n, n+1):
        sum += i
        
print (sum)




Q 8 = Write a program that reads a date as an integers in the format MMDDYYYY  . the program will call a function that prints print out the date in the format <month name > <day>,<year> .


Answer:-


mon = ["january", "february","march" , "april", "may" , "june" , "july" , "august ", "september ", "october ", "november" , 'december ']

a = int (input("enter the date  = " ))

month = a // 1000000
date = (a % 1000000) // 10000
year = a % 10000

print ( mon [ month - 1 ] , date ," , ", year )


Q 9 = Write a program that prints a table on two columns – table that helps converting miles into kilometers .


Answer:-



print("Miles        |              Kilometer")

for j in range (7) :
    print(10**j , end= "\t" )
    print(" | " , end= "\t")
    print( 1.6093  * 10** j )



Q 10 = Write another program printing a table with two columns that  helps convert pounds in kilograms .


Answer:-



print("Pounds    |              Kilogram")

for j in range (0,101,5) :
    print( j , end= "\t" )
    print(" | " , end= "\t")
    print( 0.45 *  j )


Q 11 = write a program that reads two times in military format and prints the number of hours and minutes between the two times . 


Answer:-


first = int (input("please enter the first time = "))
sec = int (input ("please enter the second time  = " ))

a =  sec - first 

print (a // 100, "hours " , a % 100, "min")

No comments:

Post a Comment