python


Fundamentals of computer programming


I'm trying to create a program that will display the number of times a specific weekday for a given month and year occurs. It's supposed to process only one request per invocation and should be aware of the number of parameters present on the command line and should display an error if there are more than three fields present. I'm having trouble figuring what to do next but the format is suppose to be [ Weekday [Month] [Year] ].
This is my code so far:
def ParseText ( text, items, errormessage ):
matches = 0
for index in range( len(items) ):
curtext = items[index].casefold()
if curtex.startwith( text.casefold() ):
matches += 1
match = index
if matches != 1:
print ( "\"%s\" is not a valid %s" % ( text, errormessage ) )
exit ( 1 ) #invalid command line argument
return match
import sys
import dates
cmdline = sys.argv
if len( cmdline ) == 1:
print ( "Usage: calcount Weekday" )
exit ( 0 )
DaysText = ( "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" )
MonthsText = ( "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" )
dayofweek = ParseText ( cmdline[1], DaysText, "day of the week" )
print ( "You have requested", DayText[dayofweek] )
for i in range(30):
print ( "DOW for January %d, 2020 is %d" % ( i, dates.weekday( 1, i, 2020 ) ) )
I'm using python 3.6.1.


Related Links

Where are flask-peewee's admin files?
Problems with sklearn's datasets
Finding the number of times characters from text1 occur in text2
itertools aparent bug with pygraphviz and return chain to flask
Encoding error after converting application into executable using py2exe and getting them from mysql (pySide, Python 3)
elegant solution to nested else-if chains
Kivy: understanding widget instances in apps
Python: converting hex values, stored as string, to hex data
Why does the execution time of the same block of python differ?
How to capture button click from customized QMessageBox?
QWidget::mouseMoveEvent not firing when cursor over child widget
Fisher's exact test for bigger than 2 by 2 contingency table
Mixing categorial and continuous data in Naive Bayes Regression using scikit-learn
How to use webbrowser.open() with request in python
logic for python web scraper for business names
Sorting a list of different values by a specific field [duplicate]

Categories

HOME
google-apps-script
system-verilog
ipython
steam
actionscript
devstack
docker-windows
httpclient
keystore
cakephp-2.9
gwtp
maxima
future
sign
redux-observable
zoomcharts
zend-framework-mvc
propel2
multicore
sonarqube-msbuild-runner
scalaz7
binutils
k2
fabric
opencart2.3
guile
bus-error
rhandsontable
web-frontend
vcard
data-conversion
reactiveui
mangodb
superagent
crt
postgresql-9.2
skygear
geo
body-parser
recurrence-relation
openpgp
lego
xen
nlb
axis-labels
equivalence
tripwire
intersystems-ensemble
tuleap
sgmlreader
webdatagrid
spring-data-hadoop
hpcc
polar-coordinates
sqldatareader
barcode-printing
sql-server-administration
inject
ruby-2.0
tomcat5
bacnet
nofollow
shipitjs
spinlock
asp.net-mvc-2
xmp
git-rebase
android-viewholder
function-fitting
intellitest
affix
xjc
divide-by-zero
graphical-logo
digits
twitter-rest-api
sparse-file
ibm-data-studio
httpie
errorprovider
libssh2
io.js
unison
help-viewer
jquery-tabs
nimrod
nscolor
va-list
ruboto
mailcore
soa-suite
deploying
shim
gjs
point-sprites
jquery-selectbox
objectbrowser
nsindexpath
charts4j
hadoop-plugins
file-encodings
front-controller
webrat
winsnmp
data-entry
interface-design
rd





Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm