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 9dd6f83

Browse files
committed
Day4
1 parent 246fa45 commit 9dd6f83

File tree

4 files changed

+74
-0
lines changed

4 files changed

+74
-0
lines changed

‎Day4/q14.py‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Write a program that computes the value of a+aa+aaa+aaaa with a given digit as the value of a.
2+
# Suppose the following input is supplied to the program:
3+
# 9
4+
# Then, the output should be:
5+
# 11106
6+
7+
8+
a = input()
9+
10+
total = int(a)+int(2*a)+int(3*a)+int(4*a)
11+
print(total)

‎Day4/q15.py‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Use a list comprehension to square each odd number in a list. The list is input by a sequence of comma-separated numbers. Suppose the following input is supplied to the program:
2+
3+
# 1,2,3,4,5,6,7,8,9
4+
# Then, the output should be:
5+
6+
# 1,3,5,7,9
7+
8+
lst = [i for i in input().split(',') if int(i) % 2]
9+
print(",".join(lst))

‎Day4/q16.py‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Define a class with a generator which can iterate the numbers, which are divisible by 7, between a
2+
# given range 0 and n.
3+
4+
5+
6+
7+
class Test:
8+
def generator(self,n):
9+
return [i for i in range(n) if i%7==0] # returns the values as a list if an element is divisible by 7
10+
11+
n = int(input())
12+
num = Test()
13+
lst = num.generator(n)
14+
print(lst)

‎Day4/q17.py‎

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# If Give an integer N . Write a program to obtain the sum of the first and last digit of this number.
2+
3+
# Input
4+
# The first line contains an integer T, total number of test cases. Then follow T lines, each line contains an integer N.
5+
6+
# Output
7+
# Display the sum of first and last digit of N.
8+
9+
# Constraints
10+
# 1 ≤ T ≤ 1000
11+
# 1 ≤ N ≤ 1000000
12+
# Example
13+
# Input
14+
# 3
15+
# 1234
16+
# 124894
17+
# 242323
18+
19+
# Output
20+
# 5
21+
# 5
22+
# 5
23+
24+
25+
def LastDigit(a):
26+
return a % 10
27+
28+
29+
def FirstDigit(a):
30+
# Remove last digit from number
31+
# till only one digit is left
32+
while(a >= 10):
33+
a /= 10
34+
return int(a)
35+
36+
37+
t = int(input())
38+
for i in range(t):
39+
number = int(input())
40+
print(LastDigit(number)+FirstDigit(number))

0 commit comments

Comments
(0)

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