Python Forum
Search Results
Post Author Forum Replies Views Posted [asc]
    Thread: Working with files and dictionaries
Post: Working with files and dictionaries

So, txt = open('testfile.txt','r') d= {} numLines = 0 #reading = txt.readlines() read = txt.readline() print(read) for line in txt.readlines(): numLines += 1 #print(numLines) if numLin...
OmarSinno General Coding Help 1 2,611 Oct-30-2017, 08:46 AM
    Thread: Red color enhancement
Post: Red color enhancement

So I wrote this code and my goal is to increase the red intensity by 50% in every pixel, help? from PIL import Image im= Image.open('monkey.jpg') img = im.copy() width, height = img.size red, green, b...
OmarSinno General Coding Help 2 5,276 Oct-23-2017, 01:19 PM
    Thread: MONEY CHANGE
Post: MONEY CHANGE

amount=int(input("Please enter amount in LBP: ")) bills = [100,50,20,10,5,1] billsReturned = [] def change(amount):     for i in bills:         while amount >=i:             billsReturned.append(i...
OmarSinno General Coding Help 5 5,581 Oct-20-2017, 09:36 AM
    Thread: Dictionaries Values
Post: Dictionaries Values

import string alphabet = string.ascii_letters d = {} for i in range(1,53): d = dict.fromkeys(alphabet,i) print(d)I want to create a dictionary of all letters in the alphabet and assign to each let...
OmarSinno General Coding Help 3 3,345 Oct-15-2017, 09:47 AM
    Thread: None problem
Post: None problem

def printbeam(): print('+----') def printtwice(): for i in range(2): printbeam() print(printtwice())I'm halfway through my code and the output is this: Output:+---- +---- NoneEveryt...
OmarSinno General Coding Help 1 2,647 Oct-14-2017, 11:42 AM
    Thread: Strings inside other strings - substrings
Post: Strings inside other strings - substrings

I have to write a function that takes a string argument str, returns the longest substring of str in which the letters occur in alphabetical order. For example if the string is 'azcbobobegghakl', then...
OmarSinno Homework 2 3,671 Oct-05-2017, 06:08 PM
    Thread: Class Error
Post: Class Error

class Students: def _init_(self,name,age,grade): self.name = name self.age = age self.grade = grade student1 = Students("Bob", 12, "7th") print(student1.name)I only want t...
OmarSinno General Coding Help 1 3,207 Sep-28-2017, 05:16 AM
    Thread: Substrings
Post: RE: Substrings

Okay, so the instructions are actually: Write a function substring(s1,s2,k) that takes two strings and an integer index k, and returns True if the first string appears as a substring in the second at ...
OmarSinno Homework 4 4,487 Sep-26-2017, 11:52 AM
    Thread: Turtle Problem
Post: RE: Turtle Problem

Changed my code to this and it worked like magic: import turtle import random colors=['blue' , 'red', 'orange', 'purple'] def cpolygon(n, size, colors): angle = 360/n for i in range(n): turtle.pe...
OmarSinno General Coding Help 2 10,396 Sep-26-2017, 07:55 AM
    Thread: Substrings
Post: Substrings

The task is to find a the first string as a substring in the other string. For example, let's say we have: string 1 = 'bob' string 2 = 'bobsbugsbegone' for i in s2: s1 == to [b]ONLY[/b] [0:2] of s2 I...
OmarSinno Homework 4 4,487 Sep-26-2017, 07:43 AM
    Thread: Turtle Problem
Post: Turtle Problem

I'm drawing a polygon in which every side of that polygon should get a random color, that means that for every side the turtle should get a different color, this is my code: import turtle import rando...
OmarSinno General Coding Help 2 10,396 Sep-26-2017, 07:31 AM
    Thread: Area of a triangle
Post: RE: Area of a triangle

It worked finally!
OmarSinno General Coding Help 8 5,790 Sep-25-2017, 08:10 PM
    Thread: Area of a triangle
Post: RE: Area of a triangle

when s1 = 2.7 s2 = 5.2 s3 = 1.3 It's giving me the ValueError mentioned before, for 10 15 and 5 it works Tried adding the (abs) still not working for THESE specific values
OmarSinno General Coding Help 8 5,790 Sep-25-2017, 07:49 PM
    Thread: Area of a triangle
Post: RE: Area of a triangle

c:\Users\OmarHS\Desktop\AUB\CMPS\200\ASST3>python triangle_asst3.py 2.7 5.2 1.3 False Traceback (most recent call last): File "triangle_asst3.py", line 22, in <module> print(area(s1, s2...
OmarSinno General Coding Help 8 5,790 Sep-25-2017, 07:18 PM
    Thread: Area of a triangle
Post: Area of a triangle

First of all I need to verify if I can draw a triangle, is_valid(s1,s2,s3): is giving correct answers. Then, I have to find the area of the triangle, the answers are also correct. Finally, when I have...
OmarSinno General Coding Help 8 5,790 Sep-25-2017, 06:45 PM
    Thread: Prime Numbers
Post: Prime Numbers

import math prime_count = 0 #This Code checks if the n integer is prime! def is_prime(n): if n % 2 == 0 and n > 2: # 2 is the only even prime return False return all(n% i for i ...
OmarSinno General Coding Help 1 4,381 Sep-23-2017, 04:51 PM
    Thread: Vowels and Consonants detector
Post: RE: Vowels and Consonants detector

Isn't c the string that is supposed to be called later on in the code? def is_vowel(c): for character in c: print(character, True) for character in c: print(character, False)I...
OmarSinno General Coding Help 5 9,791 Sep-21-2017, 12:54 PM
    Thread: Vowels and Consonants detector
Post: Vowels and Consonants detector

Objective is: to print True when it's a vowel, and False when it's a consonant, WITHOUT using if conditions. vowels = ['o', 'i', 'y', 'e', 'a','u'] consonants =['b, c, d, f, g, h, j, k, l, m ,n ,p, q...
OmarSinno General Coding Help 5 9,791 Sep-21-2017, 09:57 AM
    Thread: Factorials Problem
Post: RE: Factorials Problem

def factorial(n): if n==0: return 1 else: recurse = factorial(n-1) result = n*recurse return result for n in range(11): if n%2 !=0: print(factorial...
OmarSinno Homework 4 4,671 Sep-20-2017, 07:05 AM
    Thread: Factorials Problem
Post: RE: Factorials Problem

Hint?
OmarSinno Homework 4 4,671 Sep-20-2017, 04:14 AM

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020