Skip to content

Commit f23cde9

Browse files
committed
Q4
1 parent 1574307 commit f23cde9

File tree

4 files changed

+60
-0
lines changed

4 files changed

+60
-0
lines changed

PracticeQ1.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#Firstprogram
2+
13
#write a program to input 2 numbers & print their sum.
24

35
first = int(input("enter first :"))

PracticeQ2.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#Strings
2+
13
#WAP to input user's first name & print its length.
24

35
name = input("enter your name :")

PracticeQ3.py

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#ConditionalStatements
2+
13
#WAP to check if a number entered by the user is odd or even.
24

35
num = int(input("enter number :"))

PracticeQ4.py

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#List&Tuple
2+
3+
#WAP to ask the user to enter names of their 3 favorite movies & store them in a list.
4+
5+
movies = []
6+
mov1 = (input("enter 1st movie : "))
7+
mov2 = (input("enter 2st movie : "))
8+
mov3 = (input("enter 3st movie : "))
9+
movies.append(mov1)
10+
movies.append(mov2)
11+
movies.append(mov3)
12+
print(movies)
13+
14+
# movies = []
15+
# mov = (input("enter 1st movie : "))
16+
# movies.append(mov)
17+
# mov = (input("enter 2st movie : "))
18+
# movies.append(mov)
19+
# mov = (input("enter 3st movie : "))
20+
# movies.append(mov)
21+
# print(movies)
22+
23+
# movies = []
24+
# movies.append(input("enter 1st movie : "))
25+
# movies.append(input("enter 2st movie : "))
26+
# movies.append(input("enter 3st movie : "))
27+
28+
29+
#WAP to check if a list contains a palindrome of elements. (Hint: use copy() method)
30+
# palindrome means from starting or ending it will be same [1, 2, 3, 2, 1] [1, "abc", "abc", 1]
31+
32+
list1 = [1, 2, 1]
33+
34+
copy_list1 = list1.copy()
35+
copy_list1.reverse()
36+
37+
if(copy_list1 == list1):
38+
print("palindrome")
39+
else:
40+
print("NOT palindrome")
41+
42+
43+
#WAP to count the number of students with the "A grade in the following tuple."
44+
# ["C", "D", "A", "A", "B", "B", "A"]
45+
46+
grade = ["C", "D", "A", "A", "B", "B", "A"]
47+
print(grade.count("A"))
48+
49+
50+
#Store the above values in a list & sort them from "A" to "D".
51+
52+
grade = ["C", "D", "A", "A", "B", "B", "A"]
53+
grade.sort()
54+
print(grade)

0 commit comments

Comments
 (0)