Skip to content

Commit b28d1cf

Browse files
committed
Day5
1 parent 9dd6f83 commit b28d1cf

File tree

4 files changed

+64
-0
lines changed

4 files changed

+64
-0
lines changed

Day5/q18.py

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# cook your dish here
2+
# problem link ->"https://www.codechef.com/problems/LUCKFOUR"
3+
t=int(input())
4+
foriinrange(t):
5+
a=input()
6+
print(a.count('4'))

Day5/q19.py

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Take two lists, say for example these two:
2+
3+
# a = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89]
4+
# b = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]
5+
# and write a program that returns a list that contains only the elements that are common between the
6+
# lists (without duplicates). Make sure your program works on two lists of different sizes.
7+
8+
a= [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 13, 13, 13, 13, 12]
9+
b= [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 13, 13, 13]
10+
c= []
11+
forninb:
12+
ifninb:
13+
ifnnotinc:
14+
c.append(n)
15+
print(c)

Day5/q20.py

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Ask the user for a string and print out whether this string is
2+
# a palindrome or not. (A palindrome is a string that reads the
3+
# same forwards and backwards.)
4+
mystring=input()
5+
foriinrange(len(mystring) //2):
6+
ifmystring[i] !=mystring[-1-i]:
7+
print('Not Palindrome')
8+
break
9+
else:
10+
print('Palindrome')
11+
12+
13+
string="Hello"
14+
i=0
15+
forchinrange(len(string)):
16+
if (string[i] !=string[-1-i]):
17+
print('Not Palindrome')
18+
break
19+
else:
20+
print("Pelindrom")
21+
break
22+
23+
24+
defreverse(word):
25+
x=''
26+
foriinrange(len(word)):
27+
x+=word[len(word)-1-i]
28+
returnx
29+
30+
word=input('give me a word:\n')
31+
x=reverse(word)
32+
ifx==word:
33+
print('This is a Palindrome')
34+
else:
35+
print('This is NOT a Palindrome')

Day5/q21.py

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Let’s say I give you a list saved in a variable:
2+
# a = [1, 4, 9, 16, 25, 36, 49, 64, 81, 100]. Write one line
3+
# of Python that takes this list a and makes a new list that has only the even elements of this list in it.
4+
5+
a= [1, 4, 9, 16, 25, 36, 49, 64, 81, 100]
6+
7+
c= [numfornuminaifnum%2==0]
8+
print(c)

0 commit comments

Comments
 (0)
close