#5.15
def vowels(s):
for i in range( len(s) ):
if s[i] in "aeiouAEIOU":
print(i)
#5.16
def indexes(word, char):
' returns list of all indices where char appears in word'
inds = []
for i in range( len(word) ):
if word[i] = char:
inds.append( i )
return ind
# finalPractice.py - practice problems for final
'
Disclaimer: this is not intended to be a comprehensive
review for the exam.
I recommend that you solve these without IDLE then go back
to IDLE and make sure you understand the answers
'
# programming #
#
# midtermPractice.py - practice problems for midter
'
Disclaimer: this is not intended to be a comprehensive
review for the exam. It is intended to give you practice
solving problems similar to those that will be covered.
I recommend that you solve these
"
Paste the solutions to problems 4.17, 4.18, 4.19, and 4.20 here:
#4.17
> message = "The secret of this message is that it is secret."
> length = len( message )
> count = message.count("secret")
> censored = message.replace("secret","xxxxxx")
> censored
CSC 241
Lab #3
Due: 10 Minutes After Lab Ends
1. Implement the function returnThree that takes a string as a parameter and returns the first three
characters of the string. If the string has length less than 3, then an empty string should be
returned. The
CSC 401 ASSIGNMENT SEVEN
Due Date: Monday, Nov. 7th by 5:30 PM
The purpose of this assignment is to assess your understanding of
Encapsulation in functions
Namespaces: global vs local
Exception handling
Program modularity
Next week, we will continue with
Miranda Mo
CSC 406 HW4
long loop(long x, int n) cfw_
long result=0;
long mask;
for (mask=1; mask!=0; mask=mask<=n)cfw_
result|=(x&mask);
return result;
/collects certain bits of x
/ right most bit, and every n position
/ eg. 110100101101010101001 into 1
CSC 401 ASSIGNMENT FOUR
Due Date: Monday, Oct. 10th by 5:30 PM
The purpose of this assignment is to assess your understanding of
Reading and Writing text files
Using IF statements
FOR Loop Iteration Patterns
Passing multiple parameters in user-defined fun
400 lecture note #1
[Ch 2, 3] Logic and Proofs
1.1 Propositions (Propositional Logic)
A proposition is a statement that can be either true (T) or false (F), (but not both).
Examples:
"The earth is flat." - F
"March has 31 days." - T
"Time flies like fruit
CSC 401 ASSIGNMENT THREE
Due Date: Monday, Oct. 3rd by 5:30 PM
The purpose of this assignment is to assess your understanding of
User defined functions and parameter passing (Section 3.3 and 3.5)
String formatting (Section 4.1 and 4.2)
Iteration Structure
CSC 401-702 Intro to Programming
Final Exam
The final exam is scheduled for Monday, Nov. 21th in the Richard M. and Maggie C. Daley
Building, 14 East Jackson Building (the building with Chipotle), in Room 505.
You will have 2.25 hours (5:45 8:00 PM) to ta
CSC 401 ASSIGNMENT FIVE
Due Date: Monday, Oct. 24th by 5:30 PM
The purpose of this assignment is to assess your understanding of
Nested Loops
While Loops
Two-Dimensional Lists
Loop Pattern
Iteration Control Statements
Next week, we will continue in Chapte
CSC 401 ASSIGNMENT ONE
Due Date: Monday, Sep. 19th by 5:30 PM
The purpose of this assignment is to assess your understanding of
The basic concepts of arithmetical evaluation, variables, data types.
The process of creating a Python module (program)
Testing
import java.util.*;
public class CSC402_Week3 cfw_
public static void main(String[] args) cfw_
LinkedList<String> linkedlist = new LinkedList<String>();
/*add(String Element) is used for adding
* the elements to the linked list*/
linkedlist.add("1");
link
#Written by Miranda Mo
#CSC 401 Assignment 2
#Problem 1
AccountNumber: evalCinput("Please enter your 5 digit account number: ")
AccountType: input("Please enter '5' for Savings account, or 'C' for checkings account ")
MinBalance: eval(input("Please enter
CSC 241
Lab #2
Due: 10 minutes after lab ends
1. Write Python statements in the shell that correspond to the following:
a. Assign to variable flowers a list containing strings rose, bougainvillea, yucca, marigold,
daylilly, and lilly of the valley.
b. Wri
# hw4.py - solutions due to L. Perkovic (perhaps w/ edits by E. Sedgwick)
#5.15
def vowels(s):
for i in range( len(s) ):
if s[i] in "aeiouAEIOU":
print(i)
#5.16
def indexes(word, char):
' returns list of all indices where char appears in word'
inds = []
f
# hw3.py - solutions due to L. Perkovic (perhaps w/ edits by E. Sedgwick)
"
Paste the solutions to problems 4.17, 4.18, 4.19, and 4.20 here:
#4.17
> message = "The secret of this message is that it is secret."
> length = len( message )
> count = message.c
# hw2.py - most solutions by L. Perkovic
#solutions for hw2
#3.23 part (f)
def forLoops():
for i in range(5,22,4):
print( i )
# 3.34
def pay(hourlyWage, numHours):
if numHours <= 40:
return numHours*hourlyWage
else:
return numHours*hourlyWage+(numHours-40
# hw8.py - solutions due to L. Perkovic (perhaps w/ edits by E. Sedgwick)
# 5.42, 10.23, 10.30
# 5.42 - could also be done iteratively with nested loop
def primeFac(n):
# look, for a divisor,
# if one is found, it will be prime, recursively
# find more
fo
# hw6.py - solutions due to L. Perkovic (perhaps w/ edits by E. Sedgwick)
# 5.49
def heron( n, error):
curr = 1
while True:
curr, prev = 1/2*(curr + n/curr), curr
if abs(curr-prev)<error:
return curr
#6.22
def mirror(word):
# dict of mirrorable characters
# hw7.py - solutions due to L. Perkovic (perhaps w/ edits by E. Sedgwick)
# 5.41,10.16, 10.19, 10.29, 10.32(a)
def poly( coeffs, value):
p = 0
for i in range( len(coeffs):
p+=coeffs[i]*value*i
return p
def combinations(n,k):
if k<=0:
return 1
elif n<k:
re
# hw5.py - solutions due to L. Perkovic (perhaps w/ edits by E. Sedgwick)
#homework5.py
#5.25, 5.28, 5.36, 5.38, 5.42, 5.48
# 5.25
def leap(y):
return (y%4=0 and y%100!=0) or y%400=0
#5.28
def geometric( seq ):
# compare each ratio to first ration
# note,
#A game of Hangman
def setUp():
"shows instructions, reads file,and returns a list of words from the
english dictionary"
print(60*'*' +'\n\t\tWelcome to Hangman!\n\t
I have selected a word from an english dictionary. \n\t
I will first show you the length
#A game of Hangman
def setUp():
"shows instructions, reads file,and returns a list of words from the
english dictionary"
print(60*'*' +'\n\t\tWelcome to Hangman!\n\t
I have selected a word from an english dictionary. \n\t
I will first show you the length
CSC 401 ASSIGNMENT EIGHT
Due Date: Monday, Nov. 14th by 5:30 PM
The purpose of this assignment is to assess your understanding of
Recursive functions
Recursive thinking
Next week, we will continue with topics in Chapter 10.
SUBMISSION
Include your full na
#Written By Miranda Mo
#Final Review
#Write a recursive methond that checks if a string representing a password
#returns all character digits (0-9) in a password
#Contains at least one character that is a digit
#Prints all digits in a password
def check(s
MIDTERMS: 5:45-7:15, class after.
/* We do support the IEC 559 math functionality, real and complex. */
/* wchar_t uses ISO/IEC 10646 (2nd ed., published 2011-03-15) /
Unicode 6.0. */
/* We do not support C11 <threads.h>. */
/*
* bitAnd - x&y using only ~
CSC 401 ASSIGNMENT EIGHT
Due Date: Monday, Nov. 14th by 5:30 PM
The purpose of this assignment is to assess your understanding of
Recursive functions
Recursive thinking
Next week, we will continue with topics in Chapter 10.
SUBMISSION
Include your full na