Python- Boolean Cross-checking
<p>I have an assignment on using ONLY boolean statements for this question: "Can I register today? A student can register on Monday if Senior, on Tuesday if Junior, on Wednesday if Sophomore, and on Thursday if Freshman."</p>

<p>Is there a simple way to cross check each and every day and status to see if they are either True or False without using if/else statements? If so, how would the code look?</p>

<p>Here is a solution using a Python dictionary and Boolean comparison.  </p>

<p>We use a dictionary to create <em>student status</em> to <em>day of week</em> associations.
Then get user input and compare using a Boolean expression.</p>



<pre><code>from datetime import date
import calendar

my_dict = {'Senior' : 'Monday',
           'Junior' : 'Tuesday',
           'Sophomore' : 'Wednesday',
           'Freshman' : 'Thursday'
           }


my_date = date.today()

my_status = (raw_input("Enter your enrollment status: ")) #Student current status

today = calendar.day_name[my_date.weekday()]  #Day or week

reg_status = today == my_dict[my_status]   

#who can register today
who_can_register = my_dict.keys()[my_dict.values().index(today)] 

print "Can you register=", reg_status 
print "Today is  ", today , " Only ", who_can_register, "can register"
</code></pre>

<p>Output:</p>

<pre class="lang-none prettyprint-override"><code>Python 2.7.9 (default, Dec 10 2014, 12:24:55) [MSC v.1500 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
&gt;&gt;&gt; ================================ RESTART ================================
&gt;&gt;&gt; 
Enter your enrollment status: Senior
Can you register= False
Today is   Thursday  Only  Freshman can register
&gt;&gt;&gt; ================================ RESTART ================================
&gt;&gt;&gt; 
Enter your enrollment status: Junior
Can you register= False
Today is   Thursday  Only  Freshman can register
&gt;&gt;&gt; ================================ RESTART ================================
&gt;&gt;&gt; 
Enter your enrollment status: Sophomore
Can you register= False
Today is   Thursday  Only  Freshman can register
&gt;&gt;&gt; ================================ RESTART ================================
&gt;&gt;&gt; 
Enter your enrollment status: Freshman
Can you register= True
Today is   Thursday  Only  Freshman can register
&gt;&gt;&gt;
</code></pre>

python boolean