URA302 - Python-Programming - URA302 - (Lab - Assignment - 1) .Ipynb at Main Sparsh0106 - URA302 - Python-Programming
URA302 - Python-Programming - URA302 - (Lab - Assignment - 1) .Ipynb at Main Sparsh0106 - URA302 - Python-Programming
URA302---Python-Programming
URA302---Python-Programming / URA302_(Lab_Assignment_1).ipynb
sparsh0106 Created using Colab (uploaded by Sparsh Agarwal) f407f27 · last month
Q1. Write a Python program to print the following string in a specific format (see the
output). Sample String : "Twinkle, twinkle, little star, How I wonder what you are! Up
above the world so high, Like a diamond in the sky. Twinkle, twinkle, little star, How I
wonder what you are".
Q2. Write a Python program that accepts the user's first and last name and prints
them in reverse order with a space between them.
Q3. Write a Python program that calculates the area of a circle based on the radius
entered by the user.
Q4. Write a Python program to display the first and last colors from the following
list. color_list = ["Red","Green","White" ,"Black"]
Q5. Write a Python program that accepts an integer (n) and computes the value of
n+nn+nnn
In [ ]: n = input("Enter n : ")
print(int(n) + int(2*n) + int(3*n))
Enter n : 5
615
l =[]
for i in x:
l.append(int(i))
print(l)
l = tuple(l)
print(l)
Q8. User will input (2numbers). Write a program to swap the numbers. Add
incrementally in any one variable.
Enter no. 1: 2
Enter no. 2: 3
3.0 2.0
4.0
Q9. Write a program that will tell whether the number entered by the user is odd or
even.
Q10. Write a program that will tell whether the given year is a leap year or not.
I [ ]
In [ ]: year = int(input("Enter year : "))
if year%4 == 0:
print("Leap year")
else:
print("Not a leap year")
Q11. Write a program to find the euclidean distance between two coordinates.
In [ ]: x1 = float(input("Enter x1 : "))
x2 = float(input("Enter x2 : "))
y1 = float(input("Enter y1 : "))
y2 = float(input("Enter y2 : "))
d = ((x2-x1)**2 + (y2-y1)**2)**0.5
print(d)
Enter x1 : 0
Enter x2 : 5
Enter y1 : 0
Enter y2 : 5
7.0710678118654755
Q12. Write a program that take a user input of three angles and will find out
whether it can form a triangle or not.
Angle 1 : 60
Angle 2 : 59.9
Angle 3 : 60.1
Possible
Q14. Given a positive integer N, the task is to write a Python program to check if the
number is Prime or not in Python.
In [ ]: N = int(input("Enter a no : "))
N = int(input( Enter a no. : ))
c = 0
for i in range(2, N):
if N%i == 0:
c += 1
if c > 0:
print("Not prime")
else:
print("Prime")
Enter a no. : 41
Prime