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

In what circumstances are batch files the right approach? [closed]
Reading csv file and returning as dictionary
Send message to web skype group via a Guest account
Find max value and the corresponding column/index name in entire dataframe
ModbusTCP Server/Slave Implementat─▒on in Python (pymodbus)
Cannot stop program from crashing with wrong file entered by user
Python If Statment
How to use Async Task in django 1.10 to run in background?
flask: The requested URL was not found on this server
UnicodeDecodeError: cp932 codec can't decode byte 0x81 in position 81
Python 3.5 Selenium Webdriver IE
Python collect all checkable items in qtreeivew
How to create a data type for a periodic time interval in Python
Recording data over time in Django Models
Two Dataframes, one with more columns than the other -> Subtract and Combine
Finding the index of the first element of a list in another list

Categories

HOME
swift
ssas-2012
oauth
websphere
google-contacts
boost-thread
phonegap-cli
jpanel
simpy
constructor
height
facebook-javascript-sdk
uiactivityviewcontroller
gatsby
mod-pagespeed
uisplitviewcontroller
scaling
flat-file
zend-framework-mvc
google-api-java-client
vs2017
jive
tweets
qsub
nmf
invoke-command
getjson
strophe
expand
precedence
lego
text-files
swagger-editor
ical-dotnet
viewgroup
nashorn
xbim
html-agility-pack
cppunit
3scale
context-free-language
startapp
email-parsing
cgcontext
greenhills
openh264
tcserver
android-bitmap
jexl
modelattribute
etherpad
butterknife
search-box
jcreator
teiid
sql-import-wizard
backstop.js
update-site
instruments
multiple-file-upload
squirrel
gmsmapview
qt-linguist
handlebars.java
hateoas
drf-nested-routers
direct3d12
android-cursoradapter
jta
hornetq
apigee-baas
programming-paradigms
risk-analysis
rx-groovy
uos
swift2.1
git-checkout
orientation-changes
x-ua-compatible
dache
proxies
coin-flipping
bsod
bigint
astyanax
entity-framework-4.1
client-side-scripting
qtgui
xslkey
android-contextmenu
icsharpcode
transitive-closure-table
android-4.0
entity-framework-ctp5
paintcomponent
gtk2hs
pivotal-crm
nvelocity
asp.net-routing
webrat
hardware-infrastructure

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