Skip to content

Commit 69e10de

Browse files
committed
init: initial commit
0 parents  commit 69e10de

File tree

7 files changed

+112
-0
lines changed

7 files changed

+112
-0
lines changed

.idea/.gitignore

+6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

loopsPractice4/challenge_3.py

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Challenge
2+
# Read N, and a single digit d
3+
# Add digit d to the back of N
4+
5+
n = int(input())
6+
d = int(input())
7+
8+
# map and split functions we will learn in the later classes
9+
# for now we can use it directly
10+
# n, d = map(int, input().split())
11+
12+
print('n', n)
13+
print('d', d)
14+
15+
print(n*10 + d)
16+

loopsPractice4/code_1.py

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
class Solution:
2+
# @param A : integer
3+
# @return an integer
4+
def solve(self, A):
5+
# DO NOT TAKE ANY INPUT, INPUTS ARE PROVIDED IN THE FUNCTION
6+
# A is an INPUT
7+
# IGNORE self FOR NOW, WE WILL TALK ABOUT IT IN THE OOP CLASS
8+
9+
counter = 1
10+
final_result = 0
11+
while counter <= A:
12+
if counter % 2 == 0:
13+
# if it's even, update the final_result
14+
final_result += counter
15+
counter += 1
16+
17+
# DO NOT PRINT ANY OUTPUT
18+
# return THE OUTPUT
19+
return final_result
20+

loopsPractice4/code_2.py

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
A = int(input())
2+
3+
counter = 1
4+
final_result = 0
5+
while counter <= A:
6+
if counter % 2 == 0:
7+
# if it's even, update the final_result
8+
final_result += counter
9+
counter += 1
10+
11+
print(final_result)

loopsPractice4/print_all_digits.py

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
"""
2+
Write a code that takes a number as input and prints all the digits of that number
3+
Input: 9145
4+
"""
5+
6+
n = int(input())
7+
8+
print('Start')
9+
10+
count_of_digits = 0
11+
sum = 0
12+
while n > 0:
13+
# digit
14+
rem = n % 10
15+
print(rem)
16+
# increase the counter
17+
count_of_digits += 1
18+
# add the digit to the sum
19+
sum += rem
20+
n = n // 10
21+
22+
print('Done')
23+
print('No of digits are:', count_of_digits)
24+
print('Sum of digits is:', sum)

loopsPractice4/reverse.py

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Challenge
2+
# Read a number n and print the reverse for it
3+
# by storing it in an integer
4+
# Input: 529
5+
# Output: 925
6+
7+
n = int(input())
8+
9+
# print(n)
10+
reverse_n = 0
11+
12+
while n > 0:
13+
rem = n % 10
14+
print(rem)
15+
16+
# last challenge
17+
# adding to the end a digit
18+
reverse_n = (reverse_n * 10) + rem
19+
n = n//10
20+
print('reverse till now', reverse_n)
21+
22+
print('n is now zero', n)
23+
print(reverse_n)
24+
25+
# Now can you print the digits
26+
# 5
27+
# 2
28+
# 9
29+
30+
while reverse_n > 0:
31+
rem = reverse_n % 10
32+
print(rem)
33+
34+
reverse_n = reverse_n // 10

main.py

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
print('Hello world')

0 commit comments

Comments
 (0)