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

How to synchronize multiple django settings to the DB?
simulate pulling marbles from a bag without replacement (efficiently)
Datetime string doesn't match after strftime() and strptime()
Pandas HDFStore Tables doesn't accept multiindex columns
Two lists, if a common match is found print another list element [closed]
Is it possible to permanently change a variable inside a Python script from the same script?
Tweepy: simple script with 'Bad Authentication data' error
def function python - Help me with syntax
After the installion of django-bootstrap-toolkit, to use the css class in bootstrap, but it didn't work
Simple instructions for installing python easy_install on OSX
Python: Multiple conditions -in a pattern- for if/while
How to set timeout for ProxyAgent?
Combining data coordinates with pixel coordinates
Search/Find functionality in QTableView
is it possible to combine a logical and a limit condition in a numpy array slice operator
numpy.rint not working as expected

Categories

HOME
laravel-5
cntk
udp
vhdl
checkbox
blockchain
textwatcher
angular2-routing
cpu-architecture
youtube-livestreaming-api
qpython3
mapbox-gl-js
parse-server
survival-analysis
webdav
currency
android-viewpager
cockroachdb
wordpress-theming
cortex-a
data-analysis
qt-installer
jacoco
reduction
session-timeout
google-openid
google-people
zoho
plupload
onsen-ui
spring-test
jquery-waypoints
switching
katharsis
java-ee-7
kong
widevine
excel-2013
winscp
aurelia-binding
pygooglechart
protobuf-net
pyscripter
fractals
body-parser
salesforce-chatter
windows-10-iot-core
office365connectors
ddms
jupyter-console
datalog
g1gc
lumen-5.3
istorage
spring-data-hadoop
greenhills
pluck
modelattribute
paas
opencpu
sqlexception
project-template
android-navigationview
vst
listadapter
mpeg-4
amazon-kcl
usb-drive
eml
data-import
ninject.web.mvc
mirrorlink
code-readability
js-cookie
qbfc
ipojo
prezto
harp
ytplayerview
cpu-cores
pl-i
jcr-sql2
left-recursion
vcl
alertifyjs
initialization-vector
android-json-rpc
lov
nimrod
vmware-server
apache2.2
nuspec
manage.py
mstsc
device-emulation
qt4.6
marmalade-edk
usn
getstring
nsindexpath
text-size
tcxgrid
datacontract
rubycas
testunit
ruby-debug
nvelocity
squeel
rijndael
out-of-browser
drawtext
openwysiwyg
callgrind

Resources

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
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App