Jump to content

ColdMeekly<3

Regular
  • Content Count

    67
  • Joined

  • Last visited

Posts posted by ColdMeekly<3


  1. All they have is: Email, IP, Hashed Password, Salt

    So if anyone did sign up, just make sure that the password for the email is not the same password as the password for TeamViewer.

    Other than that, no need to worry about anything.


  2. Welcome to ColdMeekly<3's Weekly Python Challenges 2!

    Ever had the feeling that you feel that there is nothing else to do with Python*? Or do you just prefer someone setting you work instead?

    Below you will have a chance to work on code from scratch, and learn Python* that way, or you could have a look at how other people had solved the problem, and improve their code.

    Below are This Weeks Challenges, please do post your approaches if you had made an attempt, and share your experience with newcomers.
    Note: For each and every one of these i recommend to use http://trinket.io/ , Unless i specify otherwise.

    *These do not necessarily have to be done in python.

    Answers for previous questions:

    Question 1:

    Title: Lightning Distance Calculator

    Answer:

    #Ligthning Distance Calculator
    
    speedOfSound = 340 #m/s
    time = int(input("Please type the amount of second the sound was delayed for: "))
    
    distance = speedOfSound * time
    print("The ligthning struck " + str(distance) + " Miles away from you")

    Question 2:

    Title: Window Cleaner's Quotes

    Answer:

    numberOfWindows = int(input("How many windows need to be cleaned?"))
    #Asks for the user to input the amount of windows, and attempts to make it an integer
    cost = 10
    #Set the cost to 10 since the initial cost is 10
    
    for i in range(numberOfWindows):
    #Loop through, numberOfWindows times
      if i < 5:
      #If window count below or equal to 5: (Don't forget i starts with 0)
        cost += 2
        #Increment cost by 2
      elif i < 10:
      #Else, if window count below or equal to 10: (Don't forget i starts with 0)
        cost += 1.50
        #Increment cost by 1.50
      else:
      #Else, if none of the above are met:
        cost += 1
        #Increment cost by 1
    print("Your quoted cost is $" + str(cost))
    #Output the price!

    Question 3:

    Title: Sweet Shop

    Answer:

    print(" --- Price List --- ")
    print("")
    print("A -  Marshmallow: $0.20")
    print("B -  Bubble gum: $0.30")
    print("C -  Jelly Bean: $0.15")
    print("D -  Candy Stick: $0.35")
    print("E -  Cola Whips: $0.22")
    print("")
    print("X - Exit")
    print("")
    #Above, is the menu which we will print to the user.
    
    menu = {"A":[0.2,"Marshmallow"],"B":[0.3,"Bubble gum"],"C":[0.15,"Jelly Bean"],"D":[0.35,"Candy Stick"],"E":[0.22,"Cola Whip"],"X":[0]}
    #A dictionary which contains the selection Letter, price and name.
    wallet = float(input("How much do you want to spend?"))
    #Ask user for the amount of money they have.
    choice = 0
    #Initialise the choice variable to 0.
    while choice != "X":
    #While loop, which terminates program when user types "X".
      choice = str(input("Which sweet do you want to buy?"))
      #Ask the user for their selection.
      while choice not in menu:
        choice = str(input("Which sweet do you want to buy?"))
      #Keep Asking the user until they select an item from the menu.
      priceOfSweet = float(menu[choice][0])
      #Set variable to the price of the chosen sweet.
      nameOfSweet = str(menu[choice][1])
      #Set variable to the name of the chosen sweet.
      amount = int(input("How many " + nameOfSweet + "s do you want to buy?"))
      #Ask user for their desired quantity.
      cost = priceOfSweet * amount
      #Set variable to cost of the amount of sweets.
      if wallet > cost:
      #Check if the user can afford it.
        wallet -= cost
        #Take away money
        print("You had bought {} {}s for ${}.").format(amount,nameOfSweet,round(cost,2))
        print("Your wallet has ${} left.").format(wallet)
        #Print a couple bits of info back to the user
      else:
        print ("You do not have enough money for {} {}s.").format(amount,nameOfSweet)
      #Else, print that they didn't have enough money for it.
    

    Question 4:

    Title: Gradient Animation

    Info: Since this challenge consisted of many different gradients, i simply created a gradient generator, for 2 different colors.

    Answer:

    import turtle
    g=int(input("How many gradients do you want there to be?"))
    
     
    myPen = turtle.Turtle()
    myPen.speed(0)
     
    # This function draws a box by drawing each side of the square and using the fill function
    def box(height,size,r,g,b):
        myPen.color(r,g,b)
        myPen.begin_fill()
        # 0 deg.
        myPen.forward(size)
        myPen.left(90)
        # 90 deg.
        myPen.forward(height)
        myPen.left(90)
        # 180 deg.
        myPen.forward(size)
        myPen.left(90)
        # 270 deg.
        myPen.forward(height)
        myPen.end_fill()
        myPen.setheading(0)
                    
     
    #Position myPen in top left area of the screen
    myPen.penup()
    myPen.goto(-200,-100)
    myPen.pendown()
     
    #colorStartRed = input("RGB Code for color 1: Red (0-255): ")
    #colorStartGreen = input("RGB Code for color 1: Green (0-255): ")
    #colorStartBlue = input("RGB Code for color 1: Blue (0-255): ")
    colourStartArray = []
    colourEndArray = []
    colourStart = input("Please input Hex code with a #:")
    colourEnd = input("Please input Hex code with a #:")
    noHashStart=colourStart[1:]
    noHashEnd=colourEnd[1:]
    
    for i in range(0,(len(noHashStart)),2):
      hexSplit=(noHashStart[i:i+2])
      denaryNumber = int(hexSplit, 16)
      colourStartArray.append(denaryNumber)
     
    for j in range(0,(len(noHashEnd)),2):
      hexSplit=(noHashEnd[j:j+2])
      denaryNumber= int(hexSplit, 16)
      colourEndArray.append(denaryNumber)
    #colorEndRed = input("RGB Code for color 2: Red (0-255): ")
    #colorEndGreen = input("RGB Code for color 2: Green (0-255): ")
    #colorEndBlue = input("RGB Code for color 2: Blue (0-255): ")
    colourStartRed = colourStartArray[0]
    colourStartGreen = colourStartArray[1]
    colourStartBlue = colourStartArray[2]
    colourEndRed = colourEndArray[0]
    colourEndGreen = colourEndArray[1]
    colourEndBlue = colourEndArray[2]
    height = 200
     
     
    box(height, int(450/(g+2)), colourStartRed, colourStartGreen, colourStartBlue)
     
    #Replace the code below to draw an extra 6 boxes of different colours to create a gradient effect between colorStart and colorEnd
    for i in range(1,g+1):
      myPen.penup()
      myPen.forward(int(450/(g+2)))
      myPen.pendown()
      box(height ,int(450/(g+2)) , int(colourStartRed+(i*((colourEndRed-colourStartRed)/(g+1)))), int(colourStartGreen+(i*((colourEndGreen-colourStartGreen)/(g+1)))), int(colourStartBlue+(i*((colourEndBlue-colourStartBlue)/(g+1)))))
    box(height ,int(450/(g+2)) , colourEndRed, colourEndGreen, colourEndBlue)

    Question 5:

    Title: Molecular Mass Calculator

    Answer:

    import os
    import math
    import re
    def mainMenu():
      os.system('clear')
      print("Welcome to [Person]'s Molecular Mass Calculator!\n\n 1 - Single Element --> Molecular Mass\n 2 - Multiple Element --> Molecular Mass\n")
      menu = raw_input("Please choose an option from the menu")
      if menu == "1":
        a = ask()
        os.system('cls')
        print("The Molecular Mass of " + a + " is : " + str(mass(a)))
        input("\nPlease Press ENTER to continue to Main Menu...")
        mainMenu()
      elif menu == "2":
        a = ask()
        os.system('cls')
        print("The Molecular Mass of " + a + " is : " + str(converter(a)))
        input("\nPlease Press ENTER to continue to Main Menu...")
        mainMenu()
      else:
        os.system('cls')
        mainMenu()
    def ask():
      os.system('clear')
      ask = raw_input("\nPlease Enter an Element to convert :")
      return ask
    def converter(element):
      total = 0
      i = 0
      # Tested regexp ([A-Z][a-z]*)(\d*)
      # Made it simpler by ordering the elements in Atomic number order
      elements = ['H','He','Li','Be','B','C','N','O','F','Ne','Na','Mg','Al','Si','P','S','Cl','Ar','K','Ca','Sc','Ti','V','Cr','Mn','Fe','Co','Ni','Cu','Zn','Ga','Ge','As','Se','Br','Kr','Rb','Sr','Y','Zr','Nb','Mo','Tc','Ru','Rh','Pd','Ag','Cd','In','Sn','Sb','Te','I','Xe','Cs','Ba','La','Ce','Pr','Nd','Pm','Sm','Eu','Gd','Tb','Dy','Ho','Er','Tm','Yb','Lu','Hf','Ta','W','Re','Os','Ir','Pt','Au','Hg','Tl','Pb','Bi','Po','At','Rn','Fr','Ra','Ac','Th','Pa','U','Np','Pu','Am','Cm','Bk','Cf','Es','Fm','Md','No','Lr','Rf','Db','Sg','Bh','Hs','Mt','Ds','Rg','Uub','Uut','Uuq','Uup','Uuh','Uus','Uuo']
      molecularMass = ['1.0079','4.0026','6.941','9.0122','10.811','12.0107','14.0067','15.9994','18.9984','20.1797','22.9897','24.305','26.9815','28.0855','30.9738','32.065','35.453','39.0983','39.948','40.078','44.9559','47.867','50.9415','51.9961','54.938','55.845','58.6934','58.9332','63.546','65.39','69.723','72.64','74.9216','78.96','79.904','83.8','85.4678','87.62','88.9059','91.224','92.9064','95.94','98','101.07','102.9055','106.42','107.8682','112.411','114.818','118.71','121.76','126.9045','127.6','131.293','132.9055','137.327','138.9055','140.116','140.9077','144.24','145','150.36','151.964','157.25','158.9253','162.5','164.9303','167.259','168.9342','173.04','174.967','178.49','180.9479','183.84','186.207','190.23','192.217','195.078','196.9665','200.59','204.3833','207.2','208.9804','209','210','222','223','226','227','231.0359','232.0381','237','238.0289','243','244','247','247','251','252','257','258','259','261','262','262','264','266','268','272','277','0','0','0','0','0','0','0','0']
      a = re.split(r'([A-Z][a-z]*)(\d*)',element)
      lengthElement = len(element)
      i=i+1
      while '' in a:
        a.remove('')
      b = len(a) # This is total amount of Elements.
      for g in range(0,b):
        c = a[g]
        searchObj = re.search( r'([A-Z][a-z]*)(\d*)', a[g])
        index = elements.index(searchObj.group(1))
        atomic = molecularMass[index]
        if searchObj.group(2):
          total += float(atomic)*int(searchObj.group(2))
        else:
          total += float(atomic)
      return total
      print(total)
    def mass(element):
      elements = ['H','He','Li','Be','B','C','N','O','F','Ne','Na','Mg','Al','Si','P','S','Cl','Ar','K','Ca','Sc','Ti','V','Cr','Mn','Fe','Co','Ni','Cu','Zn','Ga','Ge','As','Se','Br','Kr','Rb','Sr','Y','Zr','Nb','Mo','Tc','Ru','Rh','Pd','Ag','Cd','In','Sn','Sb','Te','I','Xe','Cs','Ba','La','Ce','Pr','Nd','Pm','Sm','Eu','Gd','Tb','Dy','Ho','Er','Tm','Yb','Lu','Hf','Ta','W','Re','Os','Ir','Pt','Au','Hg','Tl','Pb','Bi','Po','At','Rn','Fr','Ra','Ac','Th','Pa','U','Np','Pu','Am','Cm','Bk','Cf','Es','Fm','Md','No','Lr','Rf','Db','Sg','Bh','Hs','Mt','Ds','Rg','Uub','Uut','Uuq','Uup','Uuh','Uus','Uuo']
      molecularMass = ['1.0079','4.0026','6.941','9.0122','10.811','12.0107','14.0067','15.9994','18.9984','20.1797','22.9897','24.305','26.9815','28.0855','30.9738','32.065','35.453','39.0983','39.948','40.078','44.9559','47.867','50.9415','51.9961','54.938','55.845','58.6934','58.9332','63.546','65.39','69.723','72.64','74.9216','78.96','79.904','83.8','85.4678','87.62','88.9059','91.224','92.9064','95.94','98','101.07','102.9055','106.42','107.8682','112.411','114.818','118.71','121.76','126.9045','127.6','131.293','132.9055','137.327','138.9055','140.116','140.9077','144.24','145','150.36','151.964','157.25','158.9253','162.5','164.9303','167.259','168.9342','173.04','174.967','178.49','180.9479','183.84','186.207','190.23','192.217','195.078','196.9665','200.59','204.3833','207.2','208.9804','209','210','222','223','226','227','231.0359','232.0381','237','238.0289','243','244','247','247','251','252','257','258','259','261','262','262','264','266','268','272','277','0','0','0','0','0','0','0','0']
      index = elements.index(element)
      mass = molecularMass[index]
      return mass
    mainMenu()

    New Challenges <3:

    Challenge #1 - Easy

    Title: How Eco Friendly Are You?
    Difficulty: Beginner
    Time Needed: 3/10
    Details:It would not be hot news for you to hear that throughout your everyday life, whatever you do, you are having an impact on the environment. Words like pollution, global warming, carbon dioxide, recycling, energy saving, waste reduction are no mystery to you.
    For this challenge you are going to design a quiz that people can take to find out how green or Eco-friendly they are. The quiz will consist of eight questions and will be used to give the end-user a score.


    Your Challenge

    Here are the eight questions for the quiz


    -------------------------------------------------------------


    How do you come to school?

    By Car (-50pts)
    By Bus (-10pts)
    On Foot (+100pts)
    Cycling (+100pts)


    Did you travel by plane in the last 12 months?

    No (+100pts)
    Yes once (-25pts)
    Yes twice (-50pts)
    At least 3 times (-100pts)


    Do you use your recycling bins at home?

    Never (-50pts)
    Rarely (+10pts)
    Often (+50pts)
    Yes every day (+100pts)


    When you go shopping do you?

    Bring your own reusable carrier bags (+20pts)
    Ask for plastic bags (-20pts)


    At home do you use Energy saving bulbs?

    Yes (+30pts)
    No (-30pts)


    When you clean your teeth, do you let the water run?

    Yes (-30pts)
    Sometimes (-10pts)
    No, never (+20pts)


    Is your house equipped with solar panels?

    Yes (+100pts)
    No (0pt)


    When it’s getting a bit colder at the end of the summer do you?

    Put an extra layer on (e.g. jumper, extra blanket) (+50pts)
    Turn the heater on? (-50pts)
    -------------------------------------------------------------

    	╔═════════════════════╦═══════════════╗
    ║        Score        ║   Category    ║
    ╠═════════════════════╬═══════════════╣
    ║ Negative score (<0) ║ Amber         ║
    ║ Between 0 and 100   ║ Light Green   ║
    ║ Between 101 and 200 ║ Emerald Green ║
    ║ Above 200           ║ Deep Green    ║
    ╚═════════════════════╩═══════════════╝
    	

    Let’s get coding:
    We have started the code for you but only completed the first question. Your task consists of:

    1.)Completing the code to ask all seven questions,
    2.)Giving the user their final score and the category they belong to (Amber, Light Green, Emerald Green or Deep Green) based on their final score.

    Don't know how to start? Check the code below:


    print("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~")
    print("~   The eco-friendly quiz   ~")
    print("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~")
    print("")
    print("Instructions: Answer each question of this test accurately. Be honest with your answers.")
    print("At the end you will be given your eco-score that tells you how eco-friendly you are!")
    print("You will be able to compare this score with your friends and hopefully be inspired to change your daily routines and become even more eco-friendly!")
    print("")

    ecoScore = 0

    print("Question 1:")
    print("How do you come to school every day?")
    answer = input("1 - By car, 2 - By bus or train, 3 - On foot, 4 - On your bike or scooter?")
    if answer=="1":
            ecoScore -= 50
    elif answer=="2":
            ecoScore -= 10
    elif answer=="3" or answer=="4":        
            ecoScore += 100
    else:
            print("Not a valid answer.")

    print("")
    print("Question 2:")
    print("How often did you take the plane over the last 12 months?")    

    	    
    ###Complete the code from here###
     
    	

    Challenge #2 - Easy

    Title: Quote of the Day
    Difficulty: Beginner
    Time Needed: 3/10
    Details:By completing this challenge you will learn how data can be stored using lists.
    You will store a series of quotes in a list and append new quotes to your list.
    You will also find out how to pick up a random value from a list using the random.choice() function.

    What is the "list" you're talking about?

    In Python, a list is used to save a collection of values. For instance, to save all the different days of the week we could declare a variable called “daysOfTheWeek” and assign a list as follows (Notice the use of square brackets):

    	daysOfTheWeek = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"]
    	

    Based on this what do you think len(daysOfTheWeek) would return?
    What’s about daysOfTheWeek[0]?
    Or daysOfTheWeek[3]?

    The Challenge:

    In this challenge we decided to create list to store a collection of inspirational quotes.
    We then randomly pick a quote from this list to display it to the end-user.

    	import random
    
    #Initialize an empty list that will be stored our bank of quotes
    quotes = []
    
    #Append a few quotes to our list
    quotes.append("The harder I work, the luckier I get.")
    quotes.append("A person who never made a mistake never tried anything new.")
    quotes.append("Nothing will work unless you do.")
    quotes.append("The best preparation for good work tomorrow is to do good work today.")
    quotes.append("Choose a job you love, and you will never have to work a day in your life.")
    
    #Randomly pick a quote from our bank of quotes
    dailyQuote = random.choice(quotes)
    
    print("############################")
    print("#     Quote of the Day     #")
    print("############################")
    print("")
    print(dailyQuote)
    	

    Your Task:

    Look at this page. Update the code above to give more daily items. For instance you could:

    Store a list of science based facts and display the “fact of the day”,
    store a list of French words and display the “French word of the day”,
    store a list of maths equations (e.g. 45 + 52 = ?) and display the “Maths Challenge of the day”, etc.

    Challenge #3 - Medium

    Title: Penalty Shootout
    Difficulty: Beginner
    Time Needed: 3/10
    Details:For this challenge you are going to write a computer program where the user tries to score a goal against the computer.

    The user will be asked where do they want to shoot and will have to choose one of the following five options:

    TL: Top Left,
    BL: Bottom Left,
    M: Middle,
    TR: Top Right,
    BR: Bottom Right.

    The computer will act as the goal keeper and randomly choose one of these options too.
    The program will decide if there is a goal or not by comparing the user’s choice with the computer option.

    Complete the code

    I have started the code for you. You need to complete it further

    	import random
    
    print("     ________________________________     ")
    print("     |                              |     ")
    print("     |                              |     ")
    print("     |       Penalty Shootout       |     ")
    print("     |                              |     ")
    print("_____|______________________________|_____")
    print("")
    print("")
    #Let the computer decides where it wants the goal to dive
    options=["TL","BL","M","TR","BR"]
    computerOption = random.choice(options)
    
    #Now let's ask the user where they want to shoot
    #Then we can check if the goal blocked the ball or not
    	

    Extension Task 1:

    Create a second level where the computer can block up to two locations which are next to each other such as:

    Bottom left and right left,
    Bottom left and middle,
    Top right and middle,
    etc.

    Extension Task 2:

    Give the end-user a choice: do they want to shoot the penalty or be the goal keeper? Adapt your code to cater for both options.

    Extension Task 3:

    Create a program where the computer and the player take it in turn. The program adds up the scores and stops on a best of 5 scores. (e.g. 3-0, 4-1, 4-2, 5-3, 5-4)

    Challenge #4 - Medium

    Title: Limit 33
    Difficulty: Intermediate
    Time Needed: 4/10
    Details:By completing this challenge you will learn about loops.

    Rules of the Game

    1. A player starts with a total of zero.
    2. On each turn a random number between 1 and 10 is generated and added to the player’s total.
    3. If the player’s total exceeds 33, the player has lost and the game ends: Game Over.
    4. At the end of each turn the player is asked whether they want to complete another turn or quit.
    5. If they quit, the player is given a score as follows:

      For instance with a total of 29, the player would score 10 x (29-23) = 60 points. The maximum score they can reach is 10 x (33-23) = 100 when they reach a total of 33!

      • Zero point if their total is below 24 or above 33.
      • 10 x (total – 23) points if their total is between 24 to 33.

    Challenge #5 - Medium

    Title: HTML Code Builder
    Difficulty: Intermediate
    Time Needed: 4/10
    Details:By completing this challenge you will learn about loops.

    Your Challenge

    Write a python script (or reuse the script above) to prompt the user to enter the number of rows and the number of columns they need for their table. The program should then generate the HTML code for the required table.

    Challenge #6 - Medium

    Title: Even Fibonacci numbers
    Difficulty: Intermediate
    Time Needed: 4/10
    Details:By completing this challenge you will about manipulating numbers.

    Your Challenge

    Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 terms will be:

    1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ...

    By considering the terms in the Fibonacci sequence whose values do not exceed four million, find the sum of the even-valued terms.

    Challenge #7 - Insane

    Title: Double base palindromes
    Difficulty: Insane
    Time Needed: 10/10
    Details:By completing this challenge you will about manipulating numbers.

    Your Challenge

    The decimal number, 585 = 10010010012 (binary), is palindromic in both bases.

    Find the sum of all numbers, less than one million, which are palindromic in base 10 and base 2.

    (Please note that the palindromic number, in either base, may not include leading zeros.)

    A palindromic number, is a number which would give the same number, no matter if it's read right to left. or left to right. (e.g. 585, 171, 1331, 68786)

    Have fun guys <3 Hope you like it!

    P.S - If people want more "Hard" challenges, request it below, i would include them :)

    Next week's is coming out on: 6/06/2016

    Answers will be released at end of week (My personal take on it)

     


  3. Nice and easy fix to start on "home.html"

    Go ahead and locate your htaccess file, or create it if you don't have one.

    and paste this inside the file:

    DirectoryIndex home.html

     


  4. 31 minutes ago, ColdMeekly<3 said:

    All quoted prices include a fixed call out fee of £10

    You nearly nailed it GunStar <3, change int price = 0; to int price = 10

    Simple and easy mistake to fix :3

     

    Additionally, could you put the answer in spoiler form? :3


  5. Welcome to ColdMeekly<3's Weekly Python Challenges!

    Ever had the feeling that you feel that there is nothing else to do with Python? Or do you just prefer someone setting you work instead?

    Below you will have a chance to work on code from scratch, and learn Python that way, or you could have a look at how other people had solved the problem, and improve their code.

    Below are This Weeks Challenges, please do post your approaches if you had made an attempt, and share your experience with newcomers.
    Note: For each and every one of these i recommend to use http://trinket.io/ , Unless i specify otherwise.

    Also, These do not necessarily have to be done in python.

    Challenge #1 - Easy

     

    Title: Lightning Distance Calculator


    Difficulty: Beginner
    Time Needed: 1/10
    Details:Have you ever seen a lightning flash or heard the thunder of lightning and wondered how close you were from the lightning strike? Have you noticed that there often was a delay between the flash of light and the clap of thunder when a lightning occurs?
    It is possible to calculate the distance to a lightning strike by counting the seconds between the lightning flash and the sound of thunder.
    When lightning strikes, the first thing you see is the flash of light which you can see instantly. This is because light travels at a very high speed (Speed of light = 300,000 km/s). At the same time a clap of thunder is created. However, in the air a sound wave does not travel as fast as light, so it may take a few seconds for this clap of thunder to reach you. This depends on how far you are from the lightning.

    Your Challenge

    Write a Python program that asks the end-user to enter a number of seconds. The program should output the distance (in meters or kilometres) from the lightning strike.

    Note that 1 mile = 1.609 km, you may want to convert this distance in miles.


    Challenge #2 - Easy

     

    Title: Window Cleaner's Quotes


    Difficulty: Beginner
    Time Needed: 2/10
    Details:A window cleaner uses the following pricing policy to calculate how much to charge for cleaning all the windows of his customer’s dwelling. This pricing policy is based on the number of windows that need to be cleaned and works as follows:

    • All quoted prices include a fixed call out fee of £10
    • Then, the first five windows are charged at £2 each
    • The next five windows are charged at £1.50 each
    • Any additional windows are charged at £1 each

    Your task is to write a computer program that prompts the end-user to enter the number of windows of their dwelling. The program will then calculate the quoted price using the pricing policy described above and display it to the end-user.


    Challenge #3 - Medium

     

    Title: Sweet Shop


    Difficulty: Intermediate
    Time Needed: 4/10
    Details:Have you ever been in a sweet shop to buy sweets? For this challenge we are going to spend £5 in a sweet shop hence we need to find out how many sweets we can afford. We will want to pick and mix sweets until we have spent all our money.

    To help us buy our sweets we are going to write a program that will help us decide how many sweets we can afford while allowing us to pick and mix different types of sweets.

    Here are the sweets available in the shop:
              ---Price List---
    A - Marshmallow: £0.20
    B - Bubble Gum: £0.30
    C - Jelly Bean: £0.15
    D - Candy Stick: £0.35
    E - Cola Whips: £0.22
    X - Exit

    Here are the main steps of our program:

    • Display a price list of all the sweets available in the shop,
    • Ask the end-user how much they would like to spend,
    • Ask the user which sweet they would like to buy and how many of them they would like (A to E),
    • Allow the user to enter X (instead of the A to E letter for a sweet) to stop buying more sweets,
    • Check whether the use can afford these and if they can, calculate and display how much money they have left,
    • Repeat steps 3 to 5 for as long as the user has some money left.


    #Sweet Shop Challenge

    
    	print(" --- Price List --- ")
    	print("")
    	print("A -  Marshmallow: $0.20")
    	print("B -  Bubble gum: $0.30")
    	print("C -  Jelly Bean: $0.15")
    	print("D -  Candy Stick: $0.35")
    	print("E -  Cola Whips: $0.22")
    	print("")
    	print("X - Exit")
    	print("")
    	money = float(input("How much do you want to spend?"))
    	#Complete the code here
    

     


    Challenge #4 - Medium

     

    Title: Gradient Animation


    Difficulty: Intermediate
    Time Needed: 6/10
    Details:In this challenge we are going to create some animated gradients by progressively changing the color of the screen from one color (e.g. red) to another (e.g. yellow).

    RGB Color codes
    Did you know that every colour on the screen can be represented using an RGB code (Red, Green, Blue) code. This code consists of three numbers between 0 and 255, indicating how much red, green and blue are used to recreate the colour.

    For instance the RGB code for:

        Red is (255,0,0)
        Green is (0,255,0)
        Blue is (0,0,255)
        Yellow is (255,255,0)
        Orange is (255,165,0)

    Learning Objective
    By completing this code we will investigate how for loops work to iterate through the code a fixed number of times.

    We will use an increment in our loop that will go up (increment) by 1 after each iteration, to count from 0 to 255. We will see that we can also use a negative step to count down from 255 to 0.
    Our first animation will be based on the following gradient:
    50e86a496ff7b72733df2a33a1f7515b.jpg
    It will consist of:

        256 frames to shade from red (255,0,0) to yellow (255,255,0)
        + another 256 frames to shade from yellow (255,255,0) back to red (255,0,0)
        It will repeat the above steps 3 times so in total will consist of (256 + 256) x 3 = 1536 frames!

    #Gradient Animation
    import turtle
    import time
    window = turtle.Screen()

    
    	#Repeat the pattern 3 times
    	for count in range(0,3):
    	  #From red (255,0,0) to yellow (255,255,0)
    	  for i in range(0,255):
    	    red = 255
    	    green = i
    	    blue = 0
    	    window.bgcolor(red,green,blue)
    	    time.sleep(0.001)
    	    
    	  #From yellow (255,255,0) to red (255,0,0)
    	  for i in range(255,0,-1):
    	    red = 255
    	    green = i
    	    blue = 0
    	    window.bgcolor(red,green,blue)
    	    time.sleep(0.001)
    


    Gradient #2: From red (255,0,0) to blue (0,0,255) to red (255,0,0)
    69eac80d9cbd71169ae761aaa63cf06d.jpg
    This code is slightly different as we want the red code to decrement from 255 to 0 while the blue code increments from 0 to 255. Check how it’s done in the code below:

    #Gradient Animation

    
    	import turtle
    	import time
    	window = turtle.Screen()
    	#Repeat the pattern 3 times
    	for count in range(0,3):
    	  #From red (255,0,0) to blue (0,0,255)
    	  for i in range(0,255):
    	    red = 255 - i
    	    green = 0
    	    blue = i
    	    window.bgcolor(red,green,blue)
    	    time.sleep(0.001)
    	    
    	  #From blue (0,0,255) to red (255,0,0)
    	  for i in range(0,255):
    	    red = i
    	    green = 0
    	    blue = 255 - i
    	    window.bgcolor(red,green,blue)
    	    time.sleep(0.001)    
    


    Complete the rest :)

    Gradient #3: From cyan (0,255,255) to magenta (255,0,255) to cyan (0,255,255)
    bcc80bf95d20fbb865136be379de6309.jpg
    Gradient #4: From cyan (0,255,255) to yellow (255,255,0) to cyan (0,255,255)
    a9ff7920edc9c66fed9ccc819d6709d0.jpg
    Gradient #5: From green (0,255,0) to yellow (255,255,0) to magenta (255,0,255) to cyan (0,255,255) to green (0,255,0)
    1a9f444ba97a192c328de6b62e391095.jpg
    Gradient #6: From black (0,0,0) to white (255,255,255) to black (0,0,0)
    d2758c33fc582d314257de4171182055.jpg


    Challenge #5 - Hard

     

    Title: Molecular Mass Calculator


    Difficulty: Advanced
    Time Needed: 9/10
    Details: Learning Objectives
    In this challenge you will improve your string manipulation techniques as well as use Python to perform some basic mathematical calculations.
    Did you know?
    The molecular weight (mass) may be calculated from the molecular formula of the substance; it is the sum of the atomic weights of the atoms making up the molecule. The molecular mass is expressed in atomic mass unit (amu).

    For example, water has the molecular formula H2O, indicating that there are two atoms of hydrogen and one atom of oxygen in a molecule of water.
    9b619cf9db9b9452763bc6ebd6975925.PNG
    n the following script we use a Python dictionary called atomicMass to store the atomic mass of some of the main atoms (C, H, O…)

    We then work out the molecular mass of water: H20.

    #Molecular Mass Calculator

    
    	atomicMass = {"H" : 1.008, "O" : 15.999, "C" : 12.011, "N" : 14.007}
    	
    	molecule = "H2O"
    	mass = atomicMass["H"] * 2 + atomicMass["O"]
    	print("\nMolecule: " + molecule + " - Mass: " + str(mass))
    


    Your Challenge
    Adapt this script to get the program ask the end-user to enter a molecular formula of their choice.
    Using string manipulation techniques your Python script will break down the formula entered by the end-user and calculate the total mass of the molecule.

    Test your script with the following molecules:
    03299479a6dbc14f3f5fe34c6af2410f.PNG

    If you are stuck, and require help: Don't hesitate and PM or visit me on TS. Or if liked my challenges and want something else a bit harder, contact me :)

    Next week's is coming out on: 27/05/2016

    Answers will be released at end of week (My personal take on it)


  6. Skeff, i can clearly see that you're against this. But don't you think that you never know how this is going to turn out? It's better to try than to just sit there and use your best predicting methods.

    After all, it doesn't cost anything to add a new section, and this can only simplify it for everyone.


  7. Additionally, if there are any "answers"/spoilers then that will ruin the challenge if the person sees it. Which they will. There are tons, tons of benefits of a separate section.

    Skeff, before mentioning the thread here, i didn't even know that the OB Computer Science thread existed. This is precisely why i came up with this SnQ <3

     


  8. Skeff, i would love to, but if anyone have any problems with previous tasks, they're going to spam all of the weeks at once. That will make it unreadable. e.g i would never read all 64 pages just to see answer to Q4


  9. Chris, This isn't for everyone on the internet. This is for our Community. And in our community we all know each other, and we can all learn from each other - and share new creations/homeworks. And don't forget, you will not find any creations which meet your criteria exactly on the internet. Where as there might be some people here up for it as a hobby.

    To be honest, for coding you would go to another place. But that's the thing i want to change! Having our own community full of smart people and even people joining because of the coding section would be fantastic. Right now, this forum is only a place where people post "updates" like in Facebook, introduce themselves and post "Applications".

    But as far as I'm concerned, this is a community and in a community, you don't leave people behind.

    The whole point of a forum, is so that people contribute to it. And I'm sure that if it's unique content that is High Quality, the admins will love you for it. This could potentially increase the size of the community and increase the amount of revenue that this project receives. Which means that you will be able to receive a larger variety of servers for example.

     

    In my opinion. if this would've been a bad idea, or wouldn't benefit the community/project; i wouldn't of even suggested anything in the first place. I'm here to promote and make sure that this amazing community stays the best. Therefore if you believe that his would "just take up space", and that "their are much better specialised resources" - then what's the point of expanding Outbreak? Why not just go on a different Forum? Why not just go on a different server?

    The amount of Custom maps created (Kriss,Skeff,Gunstar), are for all of you guys to enjoy! These guys are awesome contributors, and they could've done it somewhere else. But it's this community that they want to take care of. Same as me, i want this community to have amazing help with programming/coding. Expanding the community is always a huge plus.

     

    P.S I just realized how much i had written. And i had given up using BOLD to highlight each key-point. I apologize if you're curious and want to read through it (if you're interested in this. please read the post <3),

    so here's a quick summary: I believe that having more content will only benefit this community.

     

    EDIT: Already in this community there are several well known people who could benefit.

    OB Comp Scientists:

    Mclovin

    Gunstar

    Sjnokstaart

    Blyss

    Veng3nce

    Popey

    Substick

    Skeff

    Mintlou

    Storm


  10. Primary memory or secondary memory?

    And regarding the threads:

    I was hoping on doing weekly challenges, and i believe General Chat isn't the best option for that. If you would've had a programming section, i would've already posted a TON of very interesting content.

    people would be able to easily navigate and browse through only programming related topics. That way, even if a thread dies. It will stay inside the programming section, where as if someone is able to help/contribute, it will always be appreciated in the programming section.


  11. Lurker, i understand where you're coming from. But for example, i would love to teach other people some coding skills - as many people are interested or actually need to learn some for school.

    And as far as that's concerned, i can only do it in the "General Chat Section". Which is only for "General Chat", and would be "lost in a sea of irrelevant posts "

×
×
  • Create New...