MyStr="Keep your friends close, but your enemies closer. - The Godfather Part 2 1974"
NewStrA=''
NewStrB=''
NewStrC=''
CountSp = 0
for i in MyStr:
if MyStr.count(i)>=2:
NewStrA=NewStrA+i
NewStrB = NewStrB + MyStr[MyStr.find('T'):MyStr.find('2')+1]
for i in MyStr:
if i.isupper()==True or i.isdigit()==True:
NewStrC += i
for i in MyStr:
if i.isalpha()==False and i.isdigit()==False :
CountSp += 1
print(NewStrA)
print(NewStrB)
print(NewStrC)
print(CountSp)
ee your friends close ut your eneies closer he odfather art The Godfather Part 2 KTGP21974 16
Password = input('Please set a password:')
length_ok = len(Password) >= 8
has_upper = False
count_upper = 0
has_lower = False
count_lower = 0
has_digit = False
has_special = False
for i in Password:
if i.isupper():
count_upper += 1
elif i.islower():
count_lower += 1
elif i.isdigit():
has_digit = True
else:
has_special = True
if count_upper >= 2:
has_upper = True
if count_lower >= 2:
has_lower = True
if length_ok and has_upper and has_lower and has_digit and has_special:
print("The password is Strong")
elif length_ok or has_upper or has_lower or has_digit or has_special:
print("The password is Medium ")
else:
print("The password is Weak")
import random as r
# 1. הגדרת רשימה עם 30 איברים אקראיים
num_List = []
positives_List =[]
negatives_List =[]
for i in range(30):
num_List.append(r.randint(-10000, 10000))
# 2. הפרדה לרשימות חיוביים ושליליים
for num in num_List:
if num>0:
positives_List.append(num)
elif num<0:
negatives_List.append(num)
# 3. חישוב סכומים
sum_positives = sum(positives_List)
sum_negatives = sum(negatives_List)
# 4. בדיקה רווח / הפסד
if sum_positives + sum_negatives > 0:
result = "Positive Earnings"
else:
result = "Negative Earnings"
# הדפסת תוצאות
print("Numbers:", num_List)
print("Positives:", positives_List)
print("Negatives:", negatives_List)
print("Sum of Positives:", sum_positives)
print("Sum of Negatives:", sum_negatives)
print("Result:", result)
import random as r
N = r.randint(5, 10)
char1 = '*'
char2 = '#'
# OP1
for i in range(N):
for j in range(N):
print(char1, end='\t')
print()
for i in range(int(N/2)):
for j in range(int(N/2)):
print(char2, end='\t')
print()
# OP2
for i in range(N):
print(char1*N)
for i in range(int(N/2)):
print(char2*int(N/2))