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

Format the color of a cell in a panda dataframe according to multiple conditions
Bokeh server callback initiated from Flask application
Python Variable Amount Of Input
Turn pandas dataframe list into boolean column
How to handle concatenate with empty matrix
python django translation .po and .mo file not translating the files
jupyter not using version set by pyenv
Generalize print+format for a variable number of inputs
What are the differences in these two codes? [closed]
What is the correct way to change image channel ordering between channels first and channels last?
Python to capture screenshot of big file
How can I compare the difference between digits of two numbers?
How to find specific list among other lists
Use variable inside open and also use find and replace in python [on hold]
Can robot framework keyword can be executed in python console?
OpenMDAO/ScipyOptimizer “UnboundLocalError: local variable 'f_new' referenced before assignment”

Categories

HOME
swift
mql4
crate
oauth
checkbox
fparsec
smartphone
command
csvhelper
phonegap-cli
console
java-home
yocto
simpy
schemacrawler
openwrt
slim-3
vuex
click
metronic
cs-cart
dlib
maxima
phoenix
ejs
atlassian-plugin-sdk
google-api-java-client
linq-to-sql
thumbnails
tortoisegit
cvs2svn
autolayout
os161
onsen-ui
badge
emv
maximo
ggmap
solidworks
thinking-sphinx
skygear
m2e
transient
modulo
phpspreadsheet
von-neumann
pox
color-scheme
magiczoomplus
active-model-serializers
equivalence
visualstudio.testtools
twiki
python-idle
lumen-5.3
nsjsonserialization
recycle-bin
taskmanager
rhel6
tofixed
fontconfig
launch
restivejs
nsfetchedresultscontrolle
master
pdflib
manifest.mf
wcf-ria-services
ruby-2.0
firepath
try-finally
pax-web
gherkin
ng2-material
gmsmapview
search-regex
yoothemes
asp.net-mvc-2
web-essentials
self-hosting
geodjango
wikitext
response-headers
django-1.6
cg
suffix-array
io.js
bounds
crystal-reports-10
openkinect
lov
exiv2
gridworld
fortran77
database-permissions
device-emulation
wpdb
qsqltablemodel
datarepeater
expression-evaluation
getstring
jquery-selectbox
ajax.beginform
datacontract
django-nose
paintcomponent
testunit
ihttphandler
.app
pureftpd
drawtext
hibernate3-maven-plugin
sitemappath
multibyte-functions
asp.net-mvc-controller

Resources

Encrypt Message



code
soft
python
ios
c
html
jquery
cloud
mobile