romaji

element questions generating function

Jul 2nd, 2015
292
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.19 KB | None | 0 0
  1. def getSpecial(num,index):
  2.         while index >0:
  3.                 index-=1
  4.                 num//=2
  5.         return num
  6. def printFacts(name,symbol,atomicNum, period, group,bypass=dict()):
  7.         factTuple= (name, symbol, str(atomicNum), "Period "+str(period)+", Group "+str(group))
  8.         jTuple=("the name","the symbol","the atomic number","the Period and Group")
  9.         for I in range(4):
  10.                 if I==0:
  11.                         end=" of the element "+name+"?:"
  12.                         rev=". What is that element's name?"
  13.                 elif I==1:
  14.                         end=" of the element with symbol "+symbol+"?:"
  15.                         rev=". What is that element's symbol?"
  16.                 elif I==2:
  17.                         end=" of the element with atomic number "+factTuple[2]+"?:"
  18.                         rev=". What is that element's atomic number?"
  19.                 else:
  20.                         end=" of the element in "+factTuple[3]+"?:"
  21.                         rev=". What Period and group is this element in?"
  22.                 for J in range(4):
  23.                         if I==J or J in bypass.get(I):
  24.                                 continue
  25.                         print("What is "+jTuple[J]+end+factTuple[J]+rev)
  26.  
  27. factSet ={("Aluminum"  ,"Al",13,3,13),("Argon"    ,"Ar",18,3,18),("Arsenic"  ,"As",33,4,15),("Barium"  ,"Ba",56,6, 2),
  28.           ("Boron"     ,"B" ,5 ,2,13),("Bromine"  ,"Br",35,4,17),("Cadmium"  ,"Cd",48,5,12),("Calcium" ,"Ca",20,4, 2),
  29.           ("Carbon"    ,"C" ,6 ,2,14),("Chlorine" ,"Cl",17,3,17),("Chromium" ,"Cr",24,4, 6),("Cobalt"  ,"Co",27,4, 9),
  30.           ("Copper"    ,"Cu",29,4,11),("Fluorine" ,"F" ,9 ,2,17),("Gold"     ,"Au",79,6,11),("Helium"  ,"He",2 ,1,18),
  31.           ("Hydogen"   ,"H" ,1 ,1, 1),("Iodine"   ,"I" ,53,5,17),("Iron"     ,"Fe",26,4, 8),("Lead"    ,"Pb",82,6,14),
  32.           ("Lithium"   ,"Li",3 ,2, 1),("Magnesium","Mg",12,3, 2),("Manganese","Mn",25,4, 7),("Mercury" ,"Hg",80,6,12),
  33.           ("Neon"      ,"Ne",10,2,18),("Nickel"   ,"Ni",28,4,10),("Nitrogen" ,"N" ,7 ,2,15),("Oxygen"  ,"O" ,8 ,2,16),
  34.           ("Phosphorus","P" ,15,3,15),("Platinum" ,"Pt",78,6,10),("Potassium","K" ,19,4, 1),("Selenium","Se",34,4,16),
  35.           ("Silicon"   ,"Si",14,3,14),("Silver"   ,"Ag",47,5,11),("Sodium"   ,"Na",11,3, 1),("Sulfur"  ,"S" ,16,16,3),
  36.           ("Tin"       ,"Sn",50,5,14),("Tianium"  ,"Ti",81,6,13),("Uranium"  ,"U" ,92,7, 0),("Zinc"    ,"Zn",30,4,12)}
  37. choiceDict= dict()
  38. specialLists=((0,1,2),(0,3,4),(1,3,5),(2,4,5))
  39. import random
  40. for _ in range(40):
  41.         temp=dict()
  42.         seed=random.getrandbits(6)
  43.         for i in range(4):
  44.                 subTemp=set()
  45.                 for j in range(4):
  46.                         k=0
  47.                         if i==j:
  48.                                 continue
  49.                         if i<j:
  50.                                 k=1
  51.                         include= (k+getSpecial(seed,(specialLists[i])[j-k]))%2
  52.                         if include ==0:
  53.                                 subTemp.add(j)
  54.                 temp[i]=subTemp
  55.         choiceDict[_]=temp
  56.  
  57. print("Choices complete")
  58. _=0
  59. while len(factSet) !=0:
  60.         printFacts(*((factSet.pop())+(choiceDict.pop(_),)))
  61.         _+=1
Advertisement
Add Comment
Please, Sign In to add comment