Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Lines changed: 6 additions & 0 deletions
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+
for i in range(t):
5+
a = input()
6+
print(a.count('4'))

‎Day5/q19.py

Lines changed: 15 additions & 0 deletions
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+
for n in b:
12+
if n in b:
13+
if n not in c:
14+
c.append(n)
15+
print(c)

‎Day5/q20.py

Lines changed: 35 additions & 0 deletions
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+
for i in range(len(mystring) // 2):
6+
if mystring[i] != mystring[- 1 - i]:
7+
print('Not Palindrome')
8+
break
9+
else:
10+
print('Palindrome')
11+
12+
13+
string = "Hello"
14+
i = 0
15+
for ch in range(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+
def reverse(word):
25+
x = ''
26+
for i in range(len(word)):
27+
x += word[len(word)-1-i]
28+
return x
29+
30+
word = input('give me a word:\n')
31+
x = reverse(word)
32+
if x == word:
33+
print('This is a Palindrome')
34+
else:
35+
print('This is NOT a Palindrome')

‎Day5/q21.py

Lines changed: 8 additions & 0 deletions
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 = [num for num in a if num%2==0]
8+
print(c)

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /