File tree 4 files changed +74
-0
lines changed
4 files changed +74
-0
lines changed Original file line number Diff line number Diff line change
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 )
Original file line number Diff line number Diff line change
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 ))
Original file line number Diff line number Diff line change
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 )
Original file line number Diff line number Diff line change
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 ))
You can’t perform that action at this time.
0 commit comments