Pass with Distinction .com



Where's Wally?Where's Wally??is a popular children's book series, where you have to search through a picture for a hidden character, Wally.Write a program to try and find Wally in the text that the user inputs. If the string?Wally?appears (with a capital?W) anywhere in the user's input, your program should output?Found him!. Otherwise, your program should outputStill looking....For example:Enter some text: I saw Wally yesterdayFound him!And another example:Enter some text: He stonewally ignored herStill looking...Pass with DistinctionAt university you get a?grade for each subject?you take. The grades are allocated based on your marks. At the University of Sydney, we use the following distribution:High Distinction (HD) for a mark of 85% or betterDistinction (D) for a mark of 75% or betterCredit (CR) for a mark of 65% or betterPass (P) for a mark of 50% or betterFail (F) for a mark of less than 50%Write a program that takes a mark and tells you what grade you will get. Your program should work like this:Mark: 99Grade = HDMark: 65Grade = CRMark: 49Grade = FPython has many methods that act on strings. A subset of these methods is shown below and you should reference this list when attempting your Challenge questions. In the list the term?boolean?is the name for a type that can only hold a value of True or False and indicates that the method can be used in an?if?statement as a conditional expression.The list is in alphabetical order.capitalize() S.capitalize() -> string Return a copy of the string S with only its first character capitalized.count(sub) S.count(sub) -> int Return the number of non-overlapping occurrences of substring sub in string S. endswith(suffix) S.endswith(suffix) -> boolean Return True if S ends with the specified string suffix, False otherwise.isalnum() S.isalnum() -> boolean Return True if all characters in S are alphanumeric and there is at least one character in S, False otherwise.isalpha() S.isalpha() -> boolean Return True if all characters in S are alphabetic and there is at least one character in S, False otherwise.isdigit() S.isdigit() -> boolean Return True if all characters in S are digits and there is at least one character in S, False otherwise.islower() S.islower() -> boolean Return True if all cased characters in S are lowercase and there is at least one cased character in S, False otherwise.isspace() S.isspace() -> boolean Return True if all characters in S are whitespace and there is at least one character in S, False otherwise.istitle() S.istitle() -> boolean Return True if S is a titlecased string and there is at least one character in S, i.e. uppercase characters may only follow uncased characters and lowercase characters only cased ones. Return False otherwise.isupper() S.isupper() -> boolean Return True if all cased characters in S are uppercase and there is at least one cased character in S, False otherwise.replace(old, new) S.replace(old, new) -> string Return a copy of string S with all occurrences of substring old replaced by substring new.lower() S.lower() -> string Return a copy of the string S converted to lowercase.startswith(prefix) S.startswith(prefix) -> boolean Return True if S starts with the specified string prefix, False otherwise.title() S.title() -> string Return a titlecased version of S, i.e. words start with uppercase characters, all remaining cased characters have lowercase.EqUaLiTyWrite a Python program to read in two sentences from the user. If the two sentences are the same when you ignore the case of the letters, your program should print out?Same!. Otherwise, your program should print out?Different!.For example:Enter the first sentence: This is a testEnter the second sentence: THIS IS a TeStSame!And another example:Enter the first sentence: This is a testEnter the second sentence: This isn't the sameDifferent!Case SensitiveWrite a program to read in some text from the user. If all of the text that the user enters is capital letters or spaces, print?All capital letters.. If all of the text the user enters is lowercase letters or spaces, print?All lower letters.. Otherwise, print?Mixed letters.. You can assume that the user will always enter at least one letter of text.For example:Enter some text: this is a test sentenceAll lower letters.And another example:Enter some text: LOUD NOISESAll capital letters.And a final example:Enter some text: I saw the dogMixed letters. ................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download