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 it possible to turn a widget [Kivy]
Want to create a thumbnail(25,25) of an Image of size (181,256) using python
python code to get values from json data
Math domain error when trying to graph equation of circle with polar coordinates in python
Converting base 6 to decimal and vice versa in Python? [closed]
Labelling Segments in Turtle
How to test that functools.partial produces the expected function object
Django CreateView Auto Login
Dictionary comprehension to build list of lists: referencing the current value for a key during comprehension
Python:Errno 22 Invalid argument
Class initialisation issue python
Python def replace
How get back a proper json that was stored with fileInfo without the escape sequences?
django-admin.py not working properly in powershell
Best way to dynamically show all keys for arrays in Python
Qt5 and QtQuick 2 bindings for Python 2.7

Categories

HOME
tensorflow
sed
ncurses
deep-linking
extract
command
apollo
couchdb-2.0
sbt-assembly
wampserver
histogrammar
requirejs
constructor
eclipse-cdt
flexbox
ndis
onsen-ui2
uiscrollview
informatica-powercenter
zend-framework-mvc
propel2
styles
kadanes-algorithm
plupload
cython
excel-2010
explode
csh
philips-hue
hibernate-cache
remote-server
hashcat
nlb
image-compression
tic-tac-toe
xbim
distributed-transactions
pdftk
median
stress-testing
filepath
rdw
rapidweaver
floor
istorage
jgraph
cgcontext
pluck
mbaas
modelattribute
bettercms
ebtables
c#-interactive
software-product-lines
gitweb
angularjs-ng-pattern
multilingual-app-toolkit
mpeg-4
intellitest
optionbutton
insert-into
datasnap
paypal-nvp
subversion-edge
google-plus-one
android-search
python-ggplot
cpu-speed
node-inspector
libssh2
codeigniter-a3m
indexing-service
visualstatemanager
crystal-reports-10
bsod
installshield-2011
carddav
adomd.net
symphony-cms
abnf
marmalade-edk
mvs
blockingqueue
macruby
text-services-framework
galaxy-tab
handwriting
ruby-debug
requestfactory
camtasia
rtsp-client
multibyte-functions
kpi
internals
gears
data-execution-prevention
writing

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