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

Is there a more efficient and elegant way to filter pandas index by date?
How do I temporarily use Python 3.6 in terminal Mac?
Difference between pre-trained word embedding and training word embedding in keras
AttributeError: module 'xlwings' has no attribute 'save'
Images broadcast over UDP socket (Python)
Index class as list and as dictionary
Python “will the arrow fly straight program”
Processing an eventlog with Pandas - find next match in DataFrame
Intellij python plugin debugging the script copied under the target directory
Create a list with repeated values with list comprehension
Is LASSO regression implemented in Statsmodels?
There is a duplicate line showed when calling a __init__ in Python script
trouble with mousewheel + scrollbars in tkinter
Python Cutting a string on a certain point
Ansible become_user error UnicodeEncodeError: 'ascii' codec can't encode character
Dynamic way to create new columns as a function of existing columns in pandas

Categories

HOME
sharepoint
google-apps-script
elixir
crate
textwatcher
firebase-app-indexing
boost-thread
extract
mainframe
apollo
gspread
jpanel
google-spreadsheet-api
packer
outlook-web-addins
finite-group-theory
informatica-powercenter
store
squarespace
rebol2
titan
reduction
pyyaml
saiku
derived
jsonserializer
url.action
ghost-inspector
spring-test
bus-error
hana-studio
pygooglechart
hibernate-cache
piecewise
construct-2
preg-grep
rhomobile
honeysql
bing-maps-api
wsadmin
intellij-idea-2016
react-native-router-flux
productivity
excel-interop
recycle-bin
gd
maintenance
windows-95
mbaas
tofixed
cdk
opencpu
communication-protocol
vici
c64
xib
metalsmith
gherkin
contour
dbscan
fps
picking
usb-drive
group-concat
approval-tests
license-key
eyeql
manjaro
harp
debian-based
obfuscar
django-1.6
x-ua-compatible
em
sortable
yahoo-boss-api
surrogate-key
korma
late-static-binding
dynamic-proxy
nscolor
ruboto
stagefright
shiva3d
sharpmap
symphony-cms
prng
arbor.js
snapjs
scrollto
redirectstandardoutput
shim
die
electronic-signature
associative
adsl
pureftpd
msn
osx-leopard
unreachable-code
winsnmp
interface-design

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