Experiment 1: Basic of Python Programming
Aim: To understand Scripting Language Programming using Python to create basic syntax, keywords, and data types in Python.
Algorithm:
Step 1: Start the Python interpreter.
Step 2: Display a message using print( ) .
Step 3: Demonstrate variables of different data types: integer, float, string, boolean.
Step 4: Display the values and their types using type().
Step 5: Stop
Program:
1. Write a program to display Basic Syntax and Data Types
Source Code :
print("Hello, World!")
integer_var = 10
float_var = 3.14
string_var = "Python"
bool_var = True
print("Integer:", integer_var, "Type:", type(integer_var))
print("Float:", float_var, "Type:", type(float_var))
print("String:", string_var, "Type:", type(string_var))
print("Boolean:", bool_var, "Type:", type(bool_var))
Output:
SCREEN SHOT
Program:
2. Write a program to display Your name, Institute name, Class Roll Number, Registration number, Depertment, Semester and
Year.
Source Code :
Output:
SCREEN SHOT
Program:
3. Write a program to read variables from the user.
Source Code :
val1 = input("Enter Your Mother’s Name")
val2 = int(input("Enter Her Age: "))
val3 = float(input("Enter Her Weight"))
print("My Mother’s name is ", val1)
print("My age is ", val2)
print("My weight is ",val3,"Kg")
4. Write a program to swapping two value’s using third variable.
Output:
SCREEN SHOT
5. Write a program to swapping two value’s without using third variable.
Source Code :
Output:
SCREEN SHOT
6. Write a program to perform addition , subtraction, Multiplication, Division, Integer Division and Modulo Division on Two
Integers Numbers.
Source Code :
Output:
SCREEN SHOT
7. Write a program to perform addition , subtraction, Multiplication, Division, Integer Division and Modulo Division on Two
floating point Numbers.
Source Code :
Output:
SCREEN SHOT
8. Write a program to calculate area of triangle.
Source Code :
Output:
SCREEN SHOT
9. Write a program to convert Fahrenheit degree into degree Celsius. [c=5/9 X (f-32)].
Output:
SCREEN SHOT
10. Write a program to convert Seconds into Hours , Minutes and Seconds.
Source Code:
Output:
SCREEN SHOT
Conclusion:
After using this code, we understand that basic Python syntax and data types of simple programs were demonstrated successfully,
including how to print and read variables.