Question

Python short one to three line answers 45 a. Write a conditional that multiplies the value...

Python short one to three line answers

45 a. Write a conditional that multiplies the value assigned to pay by one-and-a-half if worked_overtime contains the value True.

b. Assume that c is a variable that has been given a string value. Write an expression whose value is True if and only if c is NOT what is called a whitespace character(space,tab, or newline)

c. Assume that c is a variable that has been given a string value. Write an expression whose value is True if and only if c is what is called a whitespace character(space,tab, or newline)

Homework Answers

Answer #1

Q45)

a) For The Conditional statement we have first check whether worked_overtime is true of not and if it is true then pay = pay *1.5

In Python We use a IF statement to do this

Expression will be : if worked_overtime == True : pay *= 1.5

Here we have used == ( equals operator ) that check true for worked_overtime and if true then pay*=1.5 is same as pay = pay * 1.5

b) If c is then it should be white space , newline character , tab .

So in the expression we will check three things 1. c is white space 2. c is newline 3. c is tab and we combine them using or operator and if anyone one gets true then value is false by negating it and if any condition is not true then true will be the value

Expression will be : !(c == ' ' or c== '\n' or c == '\t')

In Python ' ' means White space , '\n' means newline , '\t' means tab so we use == ( equals operator ) to compare each and we have negate( ! ) the output of inner bracket .

c) In this we have do the Opposite of what we did in Last Part b

So in the expression we will again check three things 1. c is white space 2. c is newline 3. c is tab and we combine them using or operator and if anyone one gets true then value is true .

Expression will be : (c == ' ' or c== '\n' or c == '\t')

Here we just remove the Negation operator and we get the desired expression

This is how we can write all three expression in one line in Python for each part

Thank You

If u like the answer then do Upvote it and have any doubt ask in comments

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Q1) Write a Python function partial_print, which takes one parameter, a string, and prints the first,...
Q1) Write a Python function partial_print, which takes one parameter, a string, and prints the first, third, fifth (and so on) characters of the strings, with each character both preceded and followed by the ^ symbol, and with a newline appearing after the last ^ symbol. The function returns no value; its goal is to print its output, but not to return it. Q2) Write a Python function called lines_of_code that takes a Path object as a parameter, which is...
solve in python 3.8 please The question is about Strings Modify your function so that it...
solve in python 3.8 please The question is about Strings Modify your function so that it can handle the following two situations: The string given as an argument has no characters. In this case, you should return the empty string. The string given as an argument has one character. In this case, you should return the one-character string given to you. Without any consideration for these cases, your function probably causes an error or returns the wrong result in the...
Write a JAVA program that reads in a string from standard input and determines the following:...
Write a JAVA program that reads in a string from standard input and determines the following: - How many vowels are in the string (FOR THE PURPOSE OF THIS PROGRAM 'Y' is NOT considered a vowel)? - How many upper case characters are in the string? - How many digits are in the string? - How many white space characters are in the string? - Modify the program to indicate which vowel occurs the most. In the case of a...
Python #Write a function called are_anagrams. The function should #have two parameters, a pair of strings....
Python #Write a function called are_anagrams. The function should #have two parameters, a pair of strings. The function should #return True if the strings are anagrams of one another, #False if they are not. # #Two strings are considered anagrams if they have only the #same letters, as well as the same count of each letter. For #this problem, you should ignore spaces and capitalization. # #So, for us: "Elvis" and "Lives" would be considered #anagrams. So would "Eleven plus...
Module 4 Assignment 1: Pseudocode & Python with Variable Scope Overview Module 4 Assignment 1 features...
Module 4 Assignment 1: Pseudocode & Python with Variable Scope Overview Module 4 Assignment 1 features the design of a calculator program using pseudocode and a Python program that uses a list and functions with variable scope to add, subtract, multiply, and divide. Open the M4Lab1ii.py program in IDLE and save it as M4Lab1ii.py with your initials instead of ii. Each lab asks you to write pseudocode that plans the program’s logic before you write the program in Python and...
Write in C++. Define a class called Text whose objects store lists of words. The class...
Write in C++. Define a class called Text whose objects store lists of words. The class Text will be just like the class StringVar except that the class Text will use a dy- namic array with base type StringVar rather than base type char and will mark the end of the array with a StringVar object consisting of a single blank, rather than using '\0' as the end marker. Intuitively, an object of the class Text represents some text consisting...
in the scheme programming language implement a game of rock paper scissors between a user and...
in the scheme programming language implement a game of rock paper scissors between a user and the computer. Only the following scheme subsets should be used: Special symbols (not case sensitive in our version (R5RS), but is in R6RS): a. Boolean: #t (else) and #f b. Characters: #\a, #\b ... #\Z c. Strings: in double quotes 3. Basic functions: a. quote b. car c. cdr d. c _ _ _ _ r, where each _ is either “a” or “d”...
#Write a function called has_a_vowel. has_a_vowel should have #one parameter, a string. It should return True...
#Write a function called has_a_vowel. has_a_vowel should have #one parameter, a string. It should return True if the string #has any vowels in it, False if it does not. def has_a_vowel(a_str): print("Starting...") for letter in a_str: print("Checking", letter) if letter in "aeiou": print(letter, "is a vowel, returning True") return True else: print(letter, "is not a vowel, returning False") return False print("Done!")       #Below are some lines of code that will test your function. #You can change the value of...
Java Please [(1)] A palindrome is a string that reads the same forwards as backwards. Using...
Java Please [(1)] A palindrome is a string that reads the same forwards as backwards. Using only a fixed number of stacks and queues, the stack and queue ADT functions, and a fixed number of int and char variables, write an algorithm to determine if a string is a palindrome. Assume that the string is read from standard input one character at a time. The algorithm should output true or false as appropriate [(2)] Let Q be a non-empty queue,...
Write a program that reads in a line consisting of a student’s name, Social Security number,...
Write a program that reads in a line consisting of a student’s name, Social Security number, user ID, and password. The program outputs the string in which all the digits of the Social Security number and all the characters in the password are replaced by x. (The Social Security number is in the form 000-00-0000, and the user ID and the password do not contain any spaces.) Your program should not use the operator [] to access a string element....
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT