0% found this document useful (0 votes)
30 views

Module-1 CS-463 Mohammad Waseem Shaikh ENROLLMENT - NO-17CS002052

This document contains source code for 11 Python programs presented as questions/tasks. The programs cover basics like printing text, performing mathematical operations like addition and calculating area, solving quadratic equations, converting units and checking conditions. For each question, the source code and output are provided. The questions demonstrate simple Python concepts like variables, conditionals, functions, input/output and built-in functions.

Uploaded by

Wasim Shaikh
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views

Module-1 CS-463 Mohammad Waseem Shaikh ENROLLMENT - NO-17CS002052

This document contains source code for 11 Python programs presented as questions/tasks. The programs cover basics like printing text, performing mathematical operations like addition and calculating area, solving quadratic equations, converting units and checking conditions. For each question, the source code and output are provided. The questions demonstrate simple Python concepts like variables, conditionals, functions, input/output and built-in functions.

Uploaded by

Wasim Shaikh
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

MODULE-1

CS- 463
MOHAMMAD WASEEM SHAIKH
ENROLLMENT.NO-17CS002052

Que.1 Program to print hello world in python.

Source code:-

print(“Hello,world!”);

output:-

Hello, world!

Que.2 Program to add two number.

Source code:-
num1 = 1.5
num2 = 6.3

sum= num1 + num2


printf(' The sum of {0} and {1} is {2}'. format (num1, num2, sum))

output:-
The sum of 1.5 and 6.3 is 7.8

Que.2 Program to calculate area of triangle.

source code:- a=5


b=6
c=7
s= (a + b +c) / 2
area = ( s* (s-a)*(s-b)*(s-c)) ** 0.5
print ( ' The area of the triangle is %0.2f ' %area)
output:-
The area of triangle is 14.70

Que4 Program to solve quadratic equation

source code:
import cmath;
a = float ( input ( 'Enter a: ') ) b =
float ( input ( 'Enter b: ') ) c = float
( input ( 'Enter c: ') ) d = (b**2) –
(4*a*c)

sol1 = ( -b-cmath.sqrt(d)) / (2*a)


sol2 = ( -b+cmath.sqrt(d)) /(2*a)
printf(' The solution are {0} and {1}' .format(sol1,sol2))

output:-
Enter a: 7
Enter b: 3
Enter c: 8
The solution are (-0.214285-1.0473484j) and (-0.21428571+ 1.04734844j)

Que.5 Program to convert celsius to fahrenheit.

Source Code:

Celsius = 37.5
fahrenheit = ( celsius * 1.8 ) + 32
printf( ' %0.1f degree celsius is equal to %0.1f degree Fahrenheit' %
(celsius,fahrenheit))

output:
37.5 degree celsius is equal to 99.5 degree fahrenhrit

Que.6 program to check number is positive negative or zero.

Source code:-
num = float (input(“ Enter a number : ”)) if num > 0;
printf(“ positive number”) elif
num ==0;
printf(“zero”) else
printf( “ Negative number”)

output:-
Enter a number : 2
positive number
Que.7 Program to check leap or

not.

Source code:-

if ( year % 4) == 0
if ( year % 100) == 0;
if ( year % 400 ) == 0;
print( “ { 0} is a leap year”. format(year))
else:
print( “ { 0} is not a leap year” .format(year))
else:
printf(“ { 0 } is a leap year”. format(year))
else:
printf( “ { 0} is not a leap year”.format(year))

output:-

2000 a leap year

Que.7 Program to find largest among three number using python.

Source
code:
num1 = 10
num2 = 14
num3 = 12

if (num1 >= num2) and (num1 >= num3):


largest = num1
elif ( num2 >=num1 ) and (num2 >= num3):
largest = num2
else:
largest = num3
printf( “The largest number is”, largest)

output:-

The largest number is” , largest )

Que.9 Program to get python version you are using.

Source code:-
import sys
print( '' python version '')
print( sys.version)
print( ''version info.'')
print(sys.version_info)
Output:-
python version
3.8.2 (default , sep 6 2020, 8:21:44
[ GCC 5.4.0 201606609]
Version info.
Sys.version_info(major=3, minor=5, micro=2, releaselevel= 'final',serial=0)

Que.11 program which accepts the user's first and last name and print them in
reverse.

You might also like