Activity 4 Introduction To Python Programming
Activity 4 Introduction To Python Programming
1. Write a Python program to read and print your name (Concept to learn: Getting familiar with
Python IDE, User input and output).
Code:
print("Hello")
Sample Output:
Hello
2. Write a Python program to read and print your name and address using the input() function.
Code:
Sample Output:
3. Write a Python program to print content of your ID – Card (Concept to learn: Formatted output).
Roll No : AU****101
NAME : KUNTAL PATEL
ADDRESS : Ahmedabad
SEAS
Ahmedabad University
Code:
rollno = input("Enter your Auris Roll number: ")
name= input("Enter name: ")
addr = input("Enter Address: ")
print("Roll No :",rollno)
print("NAME :",name)
print("ADDRESS :",addr)
print("SEAS")
print("Ahmedabad University")
Sample Output:
Enter your Auris Roll number: AU2140213
Enter name: VANAJA AGARWAL
Enter Address: AHMEDABAD
Roll No : AU2140213
NAME : VANAJA AGARWAL
ADDRESS : AHMEDABAD
SEAS
Ahmedabad University
4. Write a Python Program to get an integer input from user and display it.
Code:
no = int(input("Enter number(integer): "))
print("The entered number is: ",no)
Sample Output:
Enter number(integer): 67
The entered number is: 67
5. Write a Python program to add two given numbers.
Code:
no1 = int(input("Enter number 1: "))
no2 = int(input("Enter number 2: "))
total = no1 + no2
print("The sum of the two entered integers is :", total)
Sample Output:
Enter number 1: 23
Enter number 2: 45
The sum of the two entered integers is : 68
6. Accept two numbers from user and display average of given numbers.
Code :
no1 = int(input("Enter number 1: "))
no2 = int(input("Enter number 2: "))
avg = (no1 + no2)/2
print("The average of the two entered numbers is :", avg)
Sample Output:
Enter number 1: 12
Enter number 2: 65
The average of the two entered numbers is : 38.5
Sample Output:
Enter percentage: 99.9
The entered percentage is: 99.9
8. Write a Python program to input a number and check whether the entered number is positive or
not.
Code:
no = int(input("Enter a number :"))
if no>=0:
print("The entered number is a positive integer")
else:
print("The entered number is a negative integer")
Sample Output:
Enter a number :-4
The entered number is a negative integer
9. Write a Python program to display Good Morning message based in given time.
Code:
time = int(input("Enter time(24 hrs): "))
if time>=0 and time<12:
print("Good Morning!")
else:
print("Good Afternoon!")
Sample Output:
Enter time(24 hrs): 2
Good Morning!
Code:
no = int(input("Enter a number :"))
if (no%5)==0:
print("The entered number is divisible by 5")
else:
print("The entered number is not divisible by 5")
Sample Output:
Enter a number :35
The entered number is divisible by 5
11. Write a Python program to Convert Celsius To Fahrenheit.
Code:
celsius = float(input("Enter temperature in celsius: "))
fahrenheit = (celsius * 1.8) + 32
print(celsius," degrees C in Fahrenheit is", fahrenheit,"F")
Sample Output:
Enter temperature in celsius: 25
25.0 degrees C in Fahrenheit is 77.0 F
Practice Questions
Note: The below questions are for practice and NOT required to be submitted as
part of activity submission.
3. Write a python program input 3 numbers from user and print the maximum among them.
4. Write a python program to read marks of 3 subjects (out of 100). Calculate and print the
percentage.