Best Python code snippet using pytest-bdd_python
achievement.py
Source:achievement.py
1def record():2 3 #íì ì´ë¦ ì
ë ¥ ë° í´ë¹ íì ì±ì íì¼ ì 무 íì¸4 while True:5 name = input("\nì±ì ì íì¸íê³ ì íë íìì ì´ë¦ì ì
ë ¥íìì¤.\n")6 try:7 achievement = open("C:/Users/user/msgpro/students/{0}.txt".format(name),'r')8 break;9 except FileNotFoundError:10 print("ì¡´ì¬íì§ ìë ì´ë¦ì
ëë¤. ë¤ì ì
ë ¥íìì¤.")11 #í´ë¹ íìì´ ììí ìí ë²í¸, ì ì, ì¤ëµ ë¶ë¬ì¤ê¸°12 records = achievement.readlines()13 test_num = []14 test_score = []15 test_wrong = []16 for i in records:17 test = i.split()18 test_num.append(test[0])19 test_score.append(test[1])20 test_wrong.append(test[2:])21 22 #í´ë¹ íìì ì´ë¦, ììí ìíì ëí ì ë³´ ì¶ë ¥23 print("-----------------------------------------------------------------------------------")24 print("\níìì´ë¦:",name,"\n")25 for j in range(len(test_num)):26 print("ìíë²í¸:",test_num[j],"ì ì:",test_score[j],"í린 ë²í¸:",test_wrong[j])27 #í´ë¹ íìì íê· ì ì, íì¤í¸ì°¨ ì¶ë ¥28 avg = 029 st_dev = 030 for k in test_score:31 avg += float(k)32 avg = round(avg/len(test_num),1)33 for j in test_score:34 st_dev += (float(j)-avg)**235 st_dev = round((st_dev/len(test_num))**0.5,1)36 print("\níê· ì ì:",avg,"íì íì¤í¸ì°¨:",st_dev,"\n")37 38 #í´ë¹ íìì´ ììí ìíì ì±ì ì´ ì°ìí ììë¡ ì¶ë ¥39 print(name,"íìì ì±ì (ì±ì·¨ë)ì´ ëì ìíì ììë ë¤ìê³¼ ê°ìµëë¤.\n")40 41 for a in range(len(test_score)-1):42 for b in range(len(test_score)-1):43 if float(test_score[b]) > float(test_score[b+1]):44 test_num[b], test_num[b+1] = test_num[b+1], test_num[b]45 test_score[b], test_score[b+1] = test_score[b+1], test_score[b]46 test_wrong[b], test_wrong[b+1] = test_wrong[b+1], test_wrong[b]47 48 for j in range(len(test_num)):49 n = len(test_num)-1-j50 print("ìíë²í¸:",test_num[n],"ì ì:",test_score[n],"í린 ë²í¸:",test_wrong[n])51 ...
achievement 1.2.py
Source:achievement 1.2.py
1def record():2 3 #íì ì´ë¦ ì
ë ¥ ë° í´ë¹ íì ì±ì íì¼ ì 무 íì¸4 while True:5 name = input("\nì±ì ì íì¸íê³ ì íë íìì ì´ë¦ì ì
ë ¥íìì¤.\n")6 try:7 achievement = open("C:/Users/user/msgpro/students/{0}.txt".format(name),'r')8 break;9 except FileNotFoundError:10 print("ì¡´ì¬íì§ ìë ì´ë¦ì
ëë¤. ë¤ì ì
ë ¥íìì¤.")11 #í´ë¹ íìì´ ììí ìí ë²í¸, ì ì, ì¤ëµ ë¶ë¬ì¤ê¸°12 records = achievement.readlines()13 test_num = []14 test_score = []15 test_wrong = []16 for i in records:17 test = i.split()18 test_num.append(test[0])19 test_score.append(test[1])20 test_wrong.append(test[2:])21 22 #í´ë¹ íìì ì´ë¦, ììí ìíì ëí ì ë³´ ì¶ë ¥23 print("-----------------------------------------------------------------------------------")24 print("\níìì´ë¦:",name,"\n")25 for j in range(len(test_num)):26 print("ìíë²í¸:",test_num[j],"ì ì:",test_score[j],"í린 ë²í¸:",test_wrong[j])27 #í´ë¹ íìì íê· ì ì, íì¤í¸ì°¨ ì¶ë ¥28 avg = 029 st_dev = 030 for k in test_score:31 avg += float(k)32 avg = round(avg/len(test_num),1)33 for j in test_score:34 st_dev += (float(j)-avg)**235 st_dev = round((st_dev/len(test_num))**0.5,1)36 print("\níê· ì ì:",avg,"íì íì¤í¸ì°¨:",st_dev,"\n")37 38 #í´ë¹ íìì´ ììí ìíì ì±ì ì´ ì°ìí ììë¡ ì¶ë ¥39 print(name,"íìì ì±ì (ì±ì·¨ë)ì´ ëì ìíì ììë ë¤ìê³¼ ê°ìµëë¤.\n")40 41 for a in range(len(test_score)-1):42 for b in range(len(test_score)-1):43 if float(test_score[b]) > float(test_score[b+1]):44 test_num[b], test_num[b+1] = test_num[b+1], test_num[b]45 test_score[b], test_score[b+1] = test_score[b+1], test_score[b]46 test_wrong[b], test_wrong[b+1] = test_wrong[b+1], test_wrong[b]47 48 for j in range(len(test_num)):49 n = len(test_num)-1-j50 print("ìíë²í¸:",test_num[n],"ì ì:",test_score[n],"í린 ë²í¸:",test_wrong[n])51 ...
Rand.py
Source:Rand.py
...18 19 v = {key:val for key,val in v.items() if val!=0}20 return v21 22 def test_wrong(self, a, b , N):23 v = {k:0 for k in range(b+1)}24 for i in range(N):25 random.seed()26 randomnumber = self.value(a,b)27 v[randomnumber]+=128 29 v = {key:val for key,val in v.items() if val!=0}30 return v31'''32test = Rand(0)33v1 = test.test(3,7,10000)34v2 = test.test_wrong(3,7,10000)35print(v1)36print(v2)...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!