Skip to content

Commit 45897fa

Browse files
committed
Reformat Code by PyCharm-Community
Signed-off-by: Jérôme Krell <jerome.krell@bluewin.ch>
1 parent f538edd commit 45897fa

File tree

185 files changed

+128830
-86755
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

185 files changed

+128830
-86755
lines changed

Diff for: Assembler/assembler.py

+233-243
Large diffs are not rendered by default.

Diff for: Binary Coefficients.py

+13-14
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,20 @@
1-
def pascal_triangle( lineNumber ) :
1+
def pascal_triangle(lineNumber):
22
list1 = list()
33
list1.append([1])
4-
i=1
5-
while(i<=lineNumber):
6-
j=1
7-
l=[]
4+
i = 1
5+
while (i <= lineNumber):
6+
j = 1
7+
l = []
88
l.append(1)
9-
while(j<i):
10-
11-
l.append(list1[i-1][j]+list1[i-1][j-1])
12-
j=j+1
9+
while (j < i):
10+
l.append(list1[i - 1][j] + list1[i - 1][j - 1])
11+
j = j + 1
1312
l.append(1)
1413
list1.append(l)
15-
i=i+1
14+
i = i + 1
1615
return list1
1716

18-
def binomial_coef(n,k):
19-
pascalTriangle=pascal_triangle(n)
20-
return(pascalTriangle[n][k-1])
21-
17+
18+
def binomial_coef(n, k):
19+
pascalTriangle = pascal_triangle(n)
20+
return (pascalTriangle[n][k - 1])

Diff for: Binary_search.py

+27-27
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,37 @@
11
# It returns location of x in given array arr
22
# if present, else returns -1
3-
def binarySearch(arr, l, r, x):
4-
5-
while l <= r:
6-
7-
mid = l + (r - l)/2;
8-
3+
def binarySearch(arr, l, r, x):
4+
while l <= r:
5+
6+
mid = l + (r - l) / 2;
7+
98
# Check if x is present at mid
10-
if arr[mid] == x:
11-
return mid
12-
13-
# If x is greater, ignore left half
14-
elif arr[mid] < x:
9+
if arr[mid] == x:
10+
return mid
11+
12+
# If x is greater, ignore left half
13+
elif arr[mid] < x:
1514
l = mid + 1
16-
15+
1716
# If x is smaller, ignore right half
18-
else:
17+
else:
1918
r = mid - 1
20-
19+
2120
# If we reach here, then the element was not present
2221
return -1
23-
22+
23+
2424
# Main Function
2525
if __name__ == "__main__":
26-
# User input array
27-
print("Enter the array with comma separated in which element will be searched")
28-
arr = map(int,input().split(","))
29-
x = int(input("Enter the element you want to search in given array"))
30-
31-
# Function call
32-
result = binarySearch(arr, 0, len(arr)-1, x)
33-
34-
if result != -1:
35-
print("Element is present at index {}".format(result))
36-
else:
37-
print("Element is not present in array")
26+
# User input array
27+
print("Enter the array with comma separated in which element will be searched")
28+
arr = map(int, input().split(","))
29+
x = int(input("Enter the element you want to search in given array"))
30+
31+
# Function call
32+
result = binarySearch(arr, 0, len(arr) - 1, x)
33+
34+
if result != -1:
35+
print("Element is present at index {}".format(result))
36+
else:
37+
print("Element is not present in array")

Diff for: BlackJack_game/blackjack.py

+66-74
Original file line numberDiff line numberDiff line change
@@ -2,92 +2,86 @@
22

33
import random
44

5-
deck=[1,2,3,4,5,6,7,8,9,10,10,10,10,11]*4
5+
deck = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 11] * 4
66

77
random.shuffle(deck)
88

9+
print(
10+
" ********************************************************** ")
11+
print(
12+
" Welcome to the game Casino - BLACK JACK ! ")
13+
print(
14+
" ********************************************************** ")
915

10-
print(" ********************************************************** ")
11-
print(" Welcome to the game Casino - BLACK JACK ! ")
12-
print(" ********************************************************** ")
13-
14-
15-
d_cards = [] #Initialising dealer's cards
16-
p_cards = [] #Initialising player's cards
16+
d_cards = [] # Initialising dealer's cards
17+
p_cards = [] # Initialising player's cards
1718

1819
while len(d_cards) != 2:
19-
random.shuffle(deck)
20-
d_cards.append(deck.pop())
21-
if len(d_cards) == 2:
22-
print('The cards dealer has are X ',d_cards[1])
23-
24-
20+
random.shuffle(deck)
21+
d_cards.append(deck.pop())
22+
if len(d_cards) == 2:
23+
print('The cards dealer has are X ', d_cards[1])
2524

2625
# Displaying the Player's cards
2726
while len(p_cards) != 2:
28-
random.shuffle(deck)
29-
p_cards.append(deck.pop())
30-
if len(p_cards) == 2:
31-
print("The total of player is ",sum(p_cards))
32-
print("The cards Player has are ",p_cards)
33-
27+
random.shuffle(deck)
28+
p_cards.append(deck.pop())
29+
if len(p_cards) == 2:
30+
print("The total of player is ", sum(p_cards))
31+
print("The cards Player has are ", p_cards)
3432

3533
if sum(p_cards) > 21:
36-
print("You are BUSTED !\n **************Dealer Wins !!******************\n")
37-
exit()
34+
print("You are BUSTED !\n **************Dealer Wins !!******************\n")
35+
exit()
3836

3937
if sum(d_cards) > 21:
40-
print("Dealer is BUSTED !\n ************** You are the Winner !!******************\n")
41-
exit()
38+
print("Dealer is BUSTED !\n ************** You are the Winner !!******************\n")
39+
exit()
4240

4341
if sum(d_cards) == 21:
44-
print("***********************Dealer is the Winner !!******************")
45-
exit()
42+
print("***********************Dealer is the Winner !!******************")
43+
exit()
4644

4745
if sum(d_cards) == 21 and sum(p_cards) == 21:
48-
print("*****************The match is tie !!*************************")
49-
exit()
46+
print("*****************The match is tie !!*************************")
47+
exit()
5048

5149

5250
def dealer_choice():
53-
if sum(d_cards) < 17:
54-
while sum(d_cards) < 17:
55-
random.shuffle(deck)
56-
d_cards.append(deck.pop())
57-
58-
59-
print("Dealer has total "+ str(sum(d_cards))+"with the cards ",d_cards)
60-
61-
if sum(p_cards) == sum(d_cards):
62-
print("***************The match is tie !!****************")
63-
exit()
64-
65-
66-
if sum(d_cards) == 21:
67-
if sum(p_cards) < 21:
68-
print("***********************Dealer is the Winner !!******************")
69-
elif sum(p_cards) == 21:
70-
print("********************There is tie !!**************************")
71-
else:
72-
print("***********************Dealer is the Winner !!******************")
73-
74-
elif sum(d_cards) <21:
75-
if sum(p_cards) < 21 and sum(p_cards) < sum(d_cards):
76-
print("***********************Dealer is the Winner !!******************")
77-
if sum(p_cards) == 21:
78-
print("**********************Player is winner !!**********************")
79-
if sum(p_cards) < 21 and sum(p_cards) > sum(d_cards):
80-
print("**********************Player is winner !!**********************")
81-
82-
else:
83-
if sum(p_cards) < 21:
84-
print("**********************Player is winner !!**********************")
85-
elif sum(p_cards) == 21:
86-
print("**********************Player is winner !!**********************")
87-
else:
88-
print("***********************Dealer is the Winner !!******************")
89-
51+
if sum(d_cards) < 17:
52+
while sum(d_cards) < 17:
53+
random.shuffle(deck)
54+
d_cards.append(deck.pop())
55+
56+
print("Dealer has total " + str(sum(d_cards)) + "with the cards ", d_cards)
57+
58+
if sum(p_cards) == sum(d_cards):
59+
print("***************The match is tie !!****************")
60+
exit()
61+
62+
if sum(d_cards) == 21:
63+
if sum(p_cards) < 21:
64+
print("***********************Dealer is the Winner !!******************")
65+
elif sum(p_cards) == 21:
66+
print("********************There is tie !!**************************")
67+
else:
68+
print("***********************Dealer is the Winner !!******************")
69+
70+
elif sum(d_cards) < 21:
71+
if sum(p_cards) < 21 and sum(p_cards) < sum(d_cards):
72+
print("***********************Dealer is the Winner !!******************")
73+
if sum(p_cards) == 21:
74+
print("**********************Player is winner !!**********************")
75+
if sum(p_cards) < 21 and sum(p_cards) > sum(d_cards):
76+
print("**********************Player is winner !!**********************")
9077

78+
else:
79+
if sum(p_cards) < 21:
80+
print("**********************Player is winner !!**********************")
81+
elif sum(p_cards) == 21:
82+
print("**********************Player is winner !!**********************")
83+
else:
84+
print("***********************Dealer is the Winner !!******************")
9185

9286

9387
while sum(p_cards) < 21:
@@ -96,16 +90,14 @@ def dealer_choice():
9690
if k == 1:
9791
random.shuffle(deck)
9892
p_cards.append(deck.pop())
99-
print ('You have a total of ' + str(sum(p_cards))
100-
+ ' with the cards ', p_cards)
93+
print('You have a total of ' + str(sum(p_cards))
94+
+ ' with the cards ', p_cards)
10195
if sum(p_cards) > 21:
102-
print ('*************You are BUSTED !*************\n Dealer Wins !!')
96+
print('*************You are BUSTED !*************\n Dealer Wins !!')
10397
if sum(p_cards) == 21:
104-
print ('*******************You are the Winner !!*****************************')
98+
print('*******************You are the Winner !!*****************************')
10599

106-
107-
else:
108-
dealer_choice()
109-
break
110-
111100

101+
else:
102+
dealer_choice()
103+
break

0 commit comments

Comments
 (0)