Python 1
Python 1
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
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
Hint print(“…
Hint print(“…
Hint a=5
print(“
Hint r=10
print(
Hint p=10000,r=2,n=2
print(
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(…
Hint r=float(input(…
Hint meter=float(input(
print(“Centimetre =
Hint f=float(input(
print(“Celsius =
9. Write a program to calculate Gross Salary and Net Salary print Grade of employee
11. Write a program to swap contents of the two variables without use of third
variable
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)
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)
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)
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 )
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:
Given 2:
number1 = 40
number2 = 3
Expected Output:
The result is 43
Output Data
Expected Output :
22) Accept any city from the user and display monument of that city
city monument
Surat Dumas
Ahemdabad laldarvaja
Mumbai bombaygate
24) Accept the ,marked price from the user and calculate the net amount as (Marked
Price- Discount) to pay according to following criteria:
>10000 20%
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.
F 750
F 850
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%.
And print
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 male and age is in between 40 t0 60 then he will work in urban areas
only.
Write a python program that will check for the following conditions:
www.Shyamsir.com
Shyamsir Python Language 78 74 39 11 91
30)
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