Coder Social home page Coder Social logo

Conditionals about python HOT 17 OPEN

geekcomputers avatar geekcomputers commented on August 15, 2024
Conditionals

from python.

Comments (17)

lionpower7 avatar lionpower7 commented on August 15, 2024 1

#For Python.

mystery_int_1=int()
mystery_int_2=int()

mystery_int_1=input("Enter a Number:")
mystery_int_2=input("Enter another Number:")

if mystery_int_1% mystery_int_2 == 0 or mystery_int_2% mystery_int_1 == 0 :
print("Factors!")
else:
print(" ")`

from python.

lionpower7 avatar lionpower7 commented on August 15, 2024 1

I did It!!
Had to go back to school for this one, But Thank God I Did It.

from python.

coded92 avatar coded92 commented on August 15, 2024 1

Yeah...so correct

from python.

lionpower7 avatar lionpower7 commented on August 15, 2024 1

Problem Solved

Mystery_String = raw_input('Enter a String:'))

One = 'z'
ZZ = 'zz'
Sleepy = 'zzz'

if Sleepy in Mystery_String:
ZZ == False
One == False
print("Im Sleepy...")
elif ZZ in Mystery_String:
One == False
print("I Love ZZ Top!")
elif One in Mystery_String:
print("One is the loneliest number.")
elif One not in Mystery_String:
print("Who need's z anyway?"

from python.

lionpower7 avatar lionpower7 commented on August 15, 2024

Hey, Can I Try With Python?

I think i can do it (I am kind of new to programming but looks pretty easy...)

from python.

coded92 avatar coded92 commented on August 15, 2024

check this out

mystery_string = "zizazzle"

You may modify the lines of code above, but don't move them! When you Submit your code, we'll change these lines to assign different values to the variables.

The variable above creates a string. Add some code below that will print based on the maximum number of consecutive z's in the string:

  • If z appears three or more times in a row, print "I'm sleepy..."
  • If z appears two times in a row, print "I love ZZ Top!"
  • If z appears once, print "One is the loneliest number."
  • If z does not appear, print "Who needs z anyway?"

The message you print should correspond to the most consecutive z's: in the original value of mystery_string, for example, you'd print "I love ZZ Top!" because there are two consecutive z's, even though there are also some individual z's.

Ignore upper-case z's -- only look for lower-case z's.

Hint: Remember the 'in' operator! It returns true if the first string is found within the second string. For example, "bog" in "boggle" would return True, but "bog" in "artemis" would return False.

Comment your code

from python.

lionpower7 avatar lionpower7 commented on August 15, 2024

from python.

coded92 avatar coded92 commented on August 15, 2024

Can you do this

hour = 11
minute = 45

#You may modify the lines of code above, but don't move them!
#When you Submit your code, we'll change these lines to
#assign different values to the variables.

#Around Georgia Tech, there are plenty of places to get a
#late night bite to eat. However, they have different hours,
#so when choosing where to go, you have to think about who's
#still open!

#Imagine you're choosing between the following restaurants:

- Barrelhouse: Closes at 11:00PM

- Taco Bell: Closes at 2:00AM

- Cookout: Closes at 3:00AM

- Waffle House: Never closes. Ever.

#Assume that this list is also a priority list: if Barrelhouse
#is open, you choose Barrelhouse. If not, you choose Taco Bell
#if it's open. If not, you choose Cookout if it's open. If
#not, you choose Waffle House.

#However, there are two wrinkles:

- We're using 12-hour time.

- hour will always represent a time from 10PM to 5AM.

#That means that if hour is 10 or 11, it's PM; if hour is
#12, 1, 2, 3, 4, or 5, it's AM. This will make your reasoning
#a little more complex. You may assume that all four
#restaurants open later than 6AM, though, so you don't have
#to worry about opening time, just closing time.

#Add some code below that will print what restaurant you'll
#go to based on the current values of hour and minute.

#Add your code here!

from python.

lionpower7 avatar lionpower7 commented on August 15, 2024

x = [10,11,12,1,2,3,4,5]

y = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11,12,13,14,15,16,17,18,19,20,
21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59,]

hour = int()
minute = int()

hour = input("Enter the Hour:")
minute = input("Enter the Minute:")

if hour == x[0]:
print("BarrelHouse !!!")
elif hour == x[1]:
print("Taco Bell !!!")
elif hour == x[2]:
print("Taco Bell !!!")
elif hour == x[3]:
print("Taco Bell !!!")
elif hour == x[4]:
print("CookOut !!!")
elif hour == x[5]:
print("Waffle House !!!")

if hour not in x:
print("Enter an Hour Between 10 Pm & 5 Am!")
elif minute not in y:
raise ValueError
print("An Hour Only Has 60 Minutes!")

from python.

lionpower7 avatar lionpower7 commented on August 15, 2024

^Instead of [01,02,03,04,05,06,07,08,09], Just Enter [1,2,3,4,5,6,7,8,9]^

from python.

lionpower7 avatar lionpower7 commented on August 15, 2024

from python.

Naman-Garg-06 avatar Naman-Garg-06 commented on August 15, 2024

Mystery_String = str(input('Enter a String:'))

One = 'z'
ZZ = 'zz'
Sleepy = 'zzz'

if Sleepy in Mystery_String:
ZZ == False
One == False
print("Im Sleepy...")
elif ZZ in Mystery_String:
One == False
print("I Love ZZ Top!")
elif One in Mystery_String:
print("One is the loneliest number.")
elif One not in Mystery_String:
print("Who need's z anyway?"

In this solution, there is no need to explicitly convert the input to string as input is taken as a string only.
Also why have you denoted ZZ and One as False in the conditional part? I think thw code will rum without that also.

from python.

lionpower7 avatar lionpower7 commented on August 15, 2024

from python.

kolyamf avatar kolyamf commented on August 15, 2024

zzz = "zzz"
zz = "zz"
z = "z"
if zzz in mystery_string:
zz == False
z == False
print("I'm sleepy...")
elif zz in mystery_string:
z == False
zzz == False
print("I love ZZ Top!")
elif z in mystery_string:
zzz == False
zz == False
print("One is the loneliest number.")
else:
print("Who needs z anyway?")

from python.

Geethikagb avatar Geethikagb commented on August 15, 2024

check this out

mystery_string = "zizazzle"

You may modify the lines of code above, but don't move them! When you Submit your code, we'll change these lines to assign different values to the variables.

The variable above creates a string. Add some code below that will print based on the maximum number of consecutive z's in the string:

  • If z appears three or more times in a row, print "I'm sleepy..."
  • If z appears two times in a row, print "I love ZZ Top!"
  • If z appears once, print "One is the loneliest number."
  • If z does not appear, print "Who needs z anyway?"

The message you print should correspond to the most consecutive z's: in the original value of mystery_string, for example, you'd print "I love ZZ Top!" because there are two consecutive z's, even though there are also some individual z's.

Ignore upper-case z's -- only look for lower-case z's.

Hint: Remember the 'in' operator! It returns true if the first string is found within the second string. For example, "bog" in "boggle" would return True, but "bog" in "artemis" would return False.

Comment your code

Python 3

mystery_string = input("Enter input string : ")

if 'zzz' in mystery_string:
print("i'm sleepy...")
elif 'zz' in mystery_string:
print("i love ZZ top!")
elif 'z' in mystery_string:
print("One is the loneliest number")
else:
print("who needs z anyway")

from python.

RonaldST1996 avatar RonaldST1996 commented on August 15, 2024

Hi.
#$%!what#$%!

from python.

NitkarshChourasia avatar NitkarshChourasia commented on August 15, 2024

WORST / BAD QUALITY PROGRAMS WRITTEN ABOVE.

OP / @geekcomputers PLEASE CLOSE THIS, ASAP.

from python.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.