Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 14

Shyamsir Python Language 78 74 39 11 91

Python is a coding language

Python is an interpreted, object-oriented, high-level programming language.

www.Shyamsir.com
Shyamsir Python Language 78 74 39 11 91

1. Web development
2. Desktop app and software development
3. Processing big data and performing mathematical computations
4. System scripting.
5. Machine Learning and AI

www.Shyamsir.com
Shyamsir Python Language 78 74 39 11 91

In 1980s, by Guido van Rossum at


Centrum Wiskunde & Informatica (CWI) in
the Netherlands as a successor to the ABC
programming language.

www.Shyamsir.com
Shyamsir Python Language 78 74 39 11 91

Examples#

1 print(“Hello”)
2 print(“Hello\nhi”)
3 print(“hello\thow are u?”)
4 a=5
print(a)
print(“a”)
print(“No = “,a)
5 a=50
b=10
print(“Add = “,a+b,”Sub=”,a-b)

www.Shyamsir.com
Shyamsir Python Language 78 74 39 11 91

What is Variable?

www.Shyamsir.com
Shyamsir Python Language 78 74 39 11 91

Rules of Variable

www.Shyamsir.com
Shyamsir Python Language 78 74 39 11 91

Basic expression programs:


1. Write a program to print “HELLO WORLD”

Hint print(“…

2. Write a program to print “Name and Address”

Hint print(“…

3. Write a program to print no and its square.

Hint a=5
print(“

4. Write a program to take two numbers and print Addition, Multiplication,


Subtraction, Division.

Hint a=20 , b=2


print
print
print
print

5. Write a program to find the area of a circle (3.14*r*r)

Hint r=10
print(

6. Write a program to calculate simple interest using I = PRN/100 (P= Principle


amount, R = Rate of Interest, N = Number of Years)

Hint p=10000,r=2,n=2
print(

7. Write a program to find the area of a Triangle (0.5*H*B)

Hint H=100,B=200
print(

www.Shyamsir.com
Shyamsir Python Language 78 74 39 11 91

Input/Output programs:
1. Write a program to print no and its square.

Hint a=int(input(…..
print(…

2. Write a program to take two numbers and print Addition, Multiplication,


Subtraction, Division.

Hint a=int(input(…. , b=int(input(….


print(

3. Write a program to find the average temperature of five sunny days.

Hint day1=int(input(… , day2,day3,day4,day5


print

4. Write a program to find the area of a circle (3.14*r*r)

Hint r=float(input(…

5. Write a program to calculate simple interest using I = (P*R*N)/100 (P= Principle


amount, R = Rate of Interest, N = Number of Years)

Hint p=float(input( , r= float(input( , n = float(input(


print(“Interest =

6. Write a program to find the area of a Triangle (0.5*H*W)

Hint h=float(input( , w= float(input(


print(“Area of Triangle =

7. Convert meter to centimetre

Hint meter=float(input(
print(“Centimetre =

8. Write a program to enter the temperature in feranhit and convert it to Celsius.


[C=(f-32)*5/9]

Hint f=float(input(
print(“Celsius =

9. Write a program to calculate Gross Salary and Net Salary print Grade of employee

Gross Salary = basic + da + hra + ma + Itc + va


BASIC = 8000 ma= 10% of basic
da = 52% of basic ltc= 5% of basic
hra= 10% of basic va= 10% of basic

Net Salary = Gross Saiary - PF


www.Shyamsir.com
Shyamsir Python Language 78 74 39 11 91

Hint salary=int(input(“Enter Salary


Da=salary*
Ma=
Hra=
Va=
Netsalary=
print(“Final Salary =>

10. Write a program to swap contents of the two variables

Hint a=int(input( , b=int(input


print(“Before swap a = “,a ,” b = “,b)
logic..
print(“After swap a = “,a ,” b = “,b)

11. Write a program to swap contents of the two variables without use of third
variable

Hint a=int(input( , b=int(input


print(“Before swap a = “,a ,” b = “,b)
logic..
print(“After swap a = “,a ,” b = “,b)

12. Write a program to display the last digit of a number.

13. write a program to check whether the last digit of number (entered by user) is
divisible by 3 or not.

www.Shyamsir.com
Shyamsir Python Language 78 74 39 11 91

If else programs
1) Find out Maximum between 2 values
(Example : Enter no1 => 22 , Enter no2 =>33 then output will be 33 is max)

2) Enter one value and check whether that no is 5 or not?


(Example : Enter no => 5, Yes no is 5 , if 6 then Sorry no is not 5)

3) Enter one value and check whether that no is greater than 5 or not?
(Example : Enter no => 57, Yes no is > 5 , if 3 then Sorry no is <5)

4) Write a C program to accept two integers and check whether they are equal or
not.
(Example : Enter no1 => 57, Enter no2 => 57
Yes both are equal)

5) Write a C program to read the age of a candidate and determine whether it is


eligible for casting his/her own vote.
(Example : Enter your age => 16
Sorry you are not eligible for vote)

6) Find out whether the given no is positive or negative


(Example : Enter no => 22 then output will be 22 is positive , -3 is negative , no
is 0)

7) Find out whether the give no is odd or even or 0.


(Example : Enter no => 22 then output will be 22 is even , 23 is odd , no is 0)

8) Enter 3 subjects marks , print total , and if total>50 then display Pass else
display Fail
(Example : Enter marks of Hindi => 22 Enter marks of English =>30 Enter marks
of SS => 35 then output will be Your total 117 , you are pass)

9) Enter 3 subjects marks , print total , and if total is between 0-50 then display C
grade , 50-100 B grade and > 100 then A grade
(Example : Enter marks of Hindi => 22 Enter marks of English =>30 Enter marks
of SS => 35 then output will be Your total 117 ,you got A grade)

10)Write a C program to find the largest of three numbers.


(Example: Enter no1 => 12 Enter no2 =>25 Enter no3 => 52
Output will be
The 3rd Number is the greatest among three

11)Write a C program to find whether a given year is a leap year or not.


(Example: Enter year => 2020 , Output will be Year is leap year)

12)Write a Python program to input any alphabet and check whether it is vowel or
consonant.
(Example: Enter character => a
It's a vowel)
13)Write a Python program to input week number and print week day.
(Example: Enter week number => 2
Tuesday)

www.Shyamsir.com
Shyamsir Python Language 78 74 39 11 91
14) Write a Python program which takes two values and choice 1 2 3 4 , if user press
1 then display addition , 2 for subtraction , 3 for multiplication , 4 for division.
(Example: Enter no1 => 22
Enter no2 => 2
Enter 1 for Add
Enter 2 for Sub
Enter 3 for Mul
Enter 4 for Div
Enter =>2
Output : 24)

15)Write a Python program which takes two values and choice + - * / , if user press
+ then display addition , - for subtraction , * for multiplication , / for division.
(Example: Enter no1 => 22
Enter no2 => 2
Enter + for Add
Enter - for Sub
Enter * for Mul
Enter / for Div
Enter =>-
Output : 24)

16 ) Write a program where the user will enter the temperature and display a message
according to the temperature.
( Temp < 0 then freezing Atmosphere
Temp 0 to 10 then very cold atmosphere
Temp 10 to 20 then Cold Atmosphere
Temp 20 to 30 then normal Atmosphere
Temp 30 to 40 then hot atmosphere
Temp Greater than 40 then very hot atmosphere )

17 ) Write a program to see if the entered letter is a vowel or a consonant


(a is a vowel, h is a consonant )

18 ) Write a program to see if the entered letter is in upper case or lower case.
(a is in lowercase, A is in Uppercase)

18 ) Write a program where a user enters buying price and selling price then the output
should show if the person has made profit or loss
( buy = 400, Sell = 600, The User has made profit )

19 ) Write a Program where the user can enter any number between 1 to 9 and the
output should be the written word of the number.
( User enters 1 = One, 2 = Two )

20) Given two integer numbers return their product only if the product is equal
to or lower than 50, else return their sum.

Given 1:

number1 = 20

number2 = 30

www.Shyamsir.com
Shyamsir Python Language 78 74 39 11 91
Expected Output:

The result is 600

Given 2:

number1 = 40

number2 = 3

Expected Output:

The result is 43

21) Write a Python program to find the number of days in a month.

Output Data

Input a month number: 2

Input a year: 2016

Expected Output :

February 2016 has 29 days

22) Accept any city from the user and display monument of that city

city monument
Surat Dumas
Ahemdabad laldarvaja
Mumbai bombaygate

23) Write a program to check whether a person is senior citizen or not.

24) Accept the ,marked price from the user and calculate the net amount as (Marked
Price- Discount) to pay according to following criteria:

Marked price Discount

>10000 20%

>7000 and <=10000 15%

www.Shyamsir.com
Shyamsir Python Language 78 74 39 11 91
>=7000 10%

25) Accept the age, gender ('M',F'), number of days and display the wages accordingly.

Age Gender Wage/day

>=18 and <30 M 700

F 750

>=30 and <=40 M 800

F 850

26) A company decided to give bonus of 5% to employee if his/her year of service is


more than 5 years.

27) Ask user for their salary and year of service and print the net bonus amount.

28) Take values of length and breadth of a rectangle from user and check if it is square
or not. (hint if length and breadth is same)

29) A student will not be allowed to sit in exam if his/her attendence is less than 75%.

Take following input from user

Number of classes held

Number of classes attended.

And print

percentage of class attended (Formula , (Number of classes attended./float(Number of


classes held))*100)

Is student is allowed to sit in exam or not.

28) Ask user to enter age, gender( M or F ), marital status ( Y or N ) and then using
following rules print their place of service.

if employee is female, then she will work only in urban areas.

if employee is a male and age is in between 20 to 40 then he may work in anywhere

if employee is male and age is in between 40 t0 60 then he will work in urban areas
only.

And any other input of age should print "ERROR".

29) Traffic light

Write a python program that will check for the following conditions:

www.Shyamsir.com
Shyamsir Python Language 78 74 39 11 91

If the light is green – Car is allowed to go

If the light is yellow – Car has to wait

If the light is red – Car has to stop

Other signal – unrecognized signal. Example black, blue, etc…

30)

Given an integer, n , perform the following conditional actions:

If n is odd, print Weird

If n is even and in the inclusive range of 2 to 5, print Not Weird

If n is even and in the inclusive range of 6 to 20, print Weird

If n is even and greater than 20, print Not Weird

31)

A toy vendor supplies three types of toys: Battery Based Toys, Key-based Toys, and
Electrical Charging Based Toys.

The vendor gives a discount of 10% on orders for battery-based toys if the order is for
more than Rs. 1000.

On orders of more than Rs. 100 for key-based toys, a discount of 5% is given, and a
discount of 10% is given on orders for electrical charging based toys of value more than
Rs. 500.

Assume that the numeric codes 1,2 and 3 are used for battery based toys, key-based
toys, and electrical charging based toys respectively. Write a program that reads the
product code and the order amount and prints out the net amount that the customer is
required to pay after the discount.

www.Shyamsir.com

You might also like